conversions betwwen function pointers and their calls
Segher Boessenkool
segher@kernel.crashing.org
Sun Sep 28 21:30:00 GMT 2014
On Mon, Sep 29, 2014 at 12:06:54AM +0300, Dima Sorkin wrote:
> 1. I have read that the C99 standard allows conversions between
> function pointer types (6.3.2.3 paragraph 8). But if I don't want
> such conversions to appear mistakingly in program - is there any
> command line option to issue a warning?
-Wincompatible-pointer-types, enabled by -Wall.
> 2. Consider the example below, it was compiled by
> GCC 4.9.1 20140903 (prerelease) with
> 'gcc -std=c99 -pedantic -Wall -Wextra'. I don't understand
> why the compiler allows calling of function pointer 'g' of
> type 'void (*)()' with arguments...
Because "f()" does not mean "no arguments"; it means "unspecified
arguments". "f(void)" is "no arguments".
Segher
More information about the Gcc-help
mailing list