[vlc-commits] include/vlc_plugin.h: fixed problematic linkage on callback argument

Filip Roséen git at videolan.org
Tue Feb 23 03:26:14 CET 2016


vlc | branch: master | Filip Roséen <filip at atch.se> | Mon Feb 22 17:28:30 2016 +0100| [7abef20e8c2b6105b5f44785efefd31000553257] | committer: Rémi Denis-Courmont

include/vlc_plugin.h: fixed problematic linkage on callback argument

The rationale behind this patch is easier to explain with a little bit
of code than in words, but one can summarize it with; "wrong linkage
used for `vlc_set_cb` when `include/vlc_plugin.h` is compiled as C++,
this fixes that".

Explanation
-----------

    extern "C" typedef void(*callback_t)();

    void cpp_func (callback_t);

Above the name `cpp_func` has C++ linkage, and its type is a C++ function
returning `void`, accepting a pointer-to-function-with-C-linkage (returning
`void` and takes no arguments).

    typedef void(*callback_t) ();

    extern "C" int c_func (callback_t);

In this example (matching the code in `include/vlc_plugin.h`), the name `c_func`
has C linkage, and its type is a C function returning `int`, accepting a
pointer-to-function-with-C++-linkage (that returns `void` and takes no
arguments).

Conclusion
----------

Since `vlc_entry_*` will be called from C, the first parameter when invoked will
be a pointer to function with C linkage---as such this patch fixes the
previously erroneous linkage.

Signed-off-by: Rémi Denis-Courmont <remi at remlab.net>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7abef20e8c2b6105b5f44785efefd31000553257
---

 include/vlc_plugin.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/vlc_plugin.h b/include/vlc_plugin.h
index 46abe4e..950f6ad 100644
--- a/include/vlc_plugin.h
+++ b/include/vlc_plugin.h
@@ -234,7 +234,7 @@ enum vlc_module_properties
 #   define EXTERN_SYMBOL
 #endif
 
-typedef int (*vlc_set_cb) (void *, void *, int, ...);
+EXTERN_SYMBOL typedef int (*vlc_set_cb) (void *, void *, int, ...);
 
 #define vlc_plugin_set(...) vlc_set (opaque,   NULL, __VA_ARGS__)
 #define vlc_module_set(...) vlc_set (opaque, module, __VA_ARGS__)



More information about the vlc-commits mailing list