[cfe-dev] Is function pointer and void * incompatible?
Chris Lattner
clattner at apple.com
Thu Jan 3 14:57:30 PST 2008
On Dec 25, 2007, at 9:23 PM, Cory Nelson wrote:
> On Dec 25, 2007 7:56 PM, Sanghyeon Seo <sanxiyn at gmail.com> wrote:
>> The following code warns on clang, but does not warn on GCC.
>>
>> typedef int unary_int_func(int arg);
>> unary_int_func *func;
>>
>> void set_func(void *p) {
>> func = p;
>> }
>>
>> test.c:5:8: warning: incompatible pointer types assigning 'void *' to
>> 'unary_int_func *'
>
> Try GCC in pedantic mode. Standard says function pointers are not
> compatible with other pointers.
This is true, but we should be compatible with GCC where possible. I
changed this to be an extension warning, so it won't warn by default
anymore (unless you specify -pedantic). You should also get a better
message now.
Thanks,
-Chris
More information about the cfe-dev
mailing list