<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p>Yes and no. ISO C leaves it as a portability issue what conversion what function and void pointers do, but somewhat recommends supporting it for debugging purpose anyway.</p>
</blockquote>
<p>I did not know that; what revision of the standard and which section? I am happy to learn new stuff.</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p>Win32 & OpenGL use a different style: void (<em>)() instead of void </em>.</p>
</blockquote>
<p>The ISO C++ Standard (N3797), and I really thought ISO C did the same, considers this to be <em>undefined-behavior</em> and have no clause related to debugging purposes.</p>
<p>Using <code>void(*)()</code> instead of <code>void*</code> is in my book far better because of two main reasons:</p>
<ol style="list-style-type: decimal">
<li><p>An implementation is allowed to store code and memory in completely different manners, as such there is nothing saying that a <em>pointer-to-function</em> and <em>pointer-to-void</em> are compatible.</p></li>
<li><p>The likelyhood of different types of function-pointers having the same size is far greater than <code>sizeof(void*) == sizeof(void(*)())</code>.</p></li>
</ol>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p>I think that is more dangerous, as it allows accidental function calls without proper cast. Such a function call would fail on LP64 and LLP64 platforms due to default promotion rules.</p>
</blockquote>
<p>As a note on the above, one can of course use a <em>pointer-to-function</em> type that takes at least one argument of a type that is incompatible with everything else, having a compile-time diagnostic if such function tries to be invoked.</p>
<hr style="height:1px;margin-bottom:20px;background-color:#ddd;color:#ddd" />
<p>On 16/02/22 21:39, Rémi Denis-Courmont wrote:</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p>Le 2016-02-22 14:37, Filip Roséen a écrit :</p>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<p>NOTE</p>
<p>Related to this problem is the fact that loading of modules stores pointer-to-functions inside pointer-to-void, which is undefined-behavior according to both the C and C++ Standard.</p>
</blockquote>
</blockquote>
<p>Yes and no. ISO C leaves it as a portability issue what conversion what function and void pointers do, but somewhat recommends supporting it for debugging purpose anyway (J.5.7). POSIX makes it well defined so we do not care:</p>
<p>http://pubs.opengroup.org/onlinepubs/9699919799/functions/dlsym.html</p>
<p>Win32 & OpenGL use a different style: void (<em>)() instead of void </em>.</p>
<p>I think that is more dangerous, as it allows accidental function calls without proper cast. Such a function call would fail on LP64 and LLP64 platforms due to default promotion rules.</p>
<p>– Rémi Denis-Courmont http://www.remlab.net/ _______________________________________________ vlc-devel mailing list To unsubscribe or modify your subscription options: https://mailman.videolan.org/listinfo/vlc-devel</p>
</blockquote>