B
Bill Pursell
The following code generates a compiler warning
when compiled with gcc -pedantic:
typedef (*FUNC)(int);
FUNC f;
void *
get_f(void)
{
return &f;
}
int main(void)
{
FUNC fp;
fp = (FUNC)get_f();
return 0;
}
~
The warning is:
a.c: In function `main':
a.c:14: warning: ISO C forbids conversion of object pointer to function
pointer type
If I remove the cast, the warning is:
a.c: In function `main':
a.c:14: warning: ISO C forbids assignment between function pointer and
`void *'
Surely I can use this construction? Can I safely ignore the warning?
I'd prefer to keep -pedantic in my CFLAGS---how can I
correctly suppress the warning?
Or am I doing something wrong?
when compiled with gcc -pedantic:
typedef (*FUNC)(int);
FUNC f;
void *
get_f(void)
{
return &f;
}
int main(void)
{
FUNC fp;
fp = (FUNC)get_f();
return 0;
}
~
The warning is:
a.c: In function `main':
a.c:14: warning: ISO C forbids conversion of object pointer to function
pointer type
If I remove the cast, the warning is:
a.c: In function `main':
a.c:14: warning: ISO C forbids assignment between function pointer and
`void *'
Surely I can use this construction? Can I safely ignore the warning?
I'd prefer to keep -pedantic in my CFLAGS---how can I
correctly suppress the warning?
Or am I doing something wrong?