>>extern int fprintf __P((FILE*, __const char* format, ...));
>>1. what's __P
>some macro ... IMHO it is defined as
>#define __P(a) a
>... a do nothing macro
Not do nothing at all: such a __P definition turns the declaration into
extern int fprintf (FILE*, __const char* format, ...);
Some history follows: ignore it if you don't care about the history.
The point of such a macro is to cater to really ancient C compilers
that don't understand ISO/ANSI C function prototypes (or modern
compilers that do) without changing the header itself. Just change
the definition of __P.
Since __P begins with __, it is
in the implementor namespace and no 'legal' user code could use __P
for anything. So the macro use won't accidentally overide
or collide with some user expression/or macro.
(by ISO/ANSI C namespace rules)
Here's the point:
#define __P(a) ()
turns the original macro use into
extern int fprintf ();
as preprocessor output,
which would be acceptable to even the oldest C compiler.
Quote:>>2. (( )) means reference is to a function, not to a macro... Right?
>no ... the macro __P expects an parameter, which ist (FILE*,__const char*
>do not forget it is a macro NOT C :)
fprintf is a varargs/stdarg function. In Standard C (ignoring the
proposals for C9X and any support there might
be in gcc) there is no way to do a varargs macro.
The ((stuff,stuff))makes the (stuff,stuff) into a single macro
argument (legal in any C compiler of any age).
It's a traditional trick to allow macros to be used to call
varargs functions (at call sites or, as here, at declarations)