Re: conversions betwwen function pointers and their calls

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux