6.37. Prototypes and Old-Style Function Definitions
6.37 Prototypes and Old-Style Function Definitions
GNU C extends ISO C to allow a function prototype to override a later old-style non-prototype definition. Consider the following example:
/* Use prototypes unless the compiler is old-fashioned. */ #ifdef __STDC__ #define P(x) x #else #define P(x) () #endif /* Prototype function declaration. */ int isroot P((uid_t)); /* Old-style function definition. */ int isroot (x) /* ??? lossage here ??? */ uid_t x; { return x == 0; }
Suppose the type uid_t
happens to be short
. ISO C does not allow this example, because subword arguments in old-style non-prototype definitions are promoted. Therefore in this example the function definition's argument is really an