cfunction-pointers

Function notation for function pointer parameters in ISO C Standard


I was reading the draft of the third edition of "Modern C" by Jens Gustedt and came across a paragraph discussing the use of function notation for function pointer parameters.

Specifically, it states that using function notation emphasizes, semantically, that a null function pointer as an argument is not allowed:

/* This  emphasizes  that  the ˋˋhandler’’ argument  cannot  be null. */
int  atexit(void handler(void));
/*  Compatible  declaration  for  the  same  function.                */
int  atexit(void(* handler)(void));

However, upon examining the 3220n draft, I couldn't find any mention of this specific notation or its implications. Compiling the code with GCC trunk version doesn't yield any warnings either.

Does the use of "semantically" in the paragraph imply that this notation is merely a developer esoteric convention or is it actually defined somewhere in the C standard?


Solution

  • There is no distinction between these two declarations in the C standard. The first is automatically adjusted to be the second, making them functionally identical in the standard.

    The notion that the first conveys any intention for the pointer not to be null is entirely outside the C standard. It is a personal opinion about coding style and is one I have not seen or heard of previously. It would be hazardous to rely on it.