[vlc-devel] Callbacks in modules written in C++ have wrong linkage

Filip Roséen filip at atch.se
Mon Feb 22 21:31:12 CET 2016

Now that I am looking through the ISO C Standard (N1570) I see that
casts from one pointer-to-function type to another pointer-to-function
type and back again is actually well-defined (TIL):

    A pointer to a function of one type may be converted to a pointer to
    a function of another type and back again; the result shall copare
    equal to the original pointer. If a converted pointer is used to
    call a function whose type is not compatible with the pointed-to
    type, the behavior is undefined.

In other words, the quoted section from my previous post is errornous in
the sense that "the likelyhood" is actually "guaranteed" (in ISO C,
afaik there is no such clause in the ISO C++ Standard).

The wording in ISO C has not changed since the C89 draft.


On 16/02/22 20:59, Filip Roséen wrote:

>   2. The likelyhood of different types of function-pointers having the same size
>      is far greater than `sizeof(void*) == sizeof(void(*)())`.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20160222/fb92e4bd/attachment.html>

More information about the vlc-devel mailing list