#if defined(__STDC__) || defined(__cplusplus)
#define __P(protos) protos /* full-blown ANSI C */
#define __CONCAT(x,y) x ## y
#define __STRING(x) #x
#define __unused __attribute__((__unused__))
#define __dead2 __attribute__((__noreturn__))
#define __pure2 __attribute__((__const__))
protos
? Where is it defined?#x
?__unused
when __unused__
already existed?__const__
, __noreturn__
, __unused__
defined?protos
is the macro parameter. It's defined in __P(protos)
and its scope is until the end of the line. In this case, the macro invocation int func(__P(int foo))
would be replaced by int func(int foo)
, which is an "ANSI style" function prototype, as opposed to pre-standard C which did not necessarily declare function parameters. On such a pre-standard compiler, the macro would be defined with no expansion, so the compiler would see only int func()
.
#x
is the stringize operator. It turns the content of its argument x
into a string by adding quotes. If the argument passed to x
contains macros, they are not expanded before the string conversion is done.
These macros are used to define different things for different platforms. __unused
might expand to different things on GCC or MSVC.
They are hooks to the inside of the compiler. The header file is providing an interface between the compiler internals and the standard language. The compiler could work directly with __unused
as an extension keyword, but its authors preferred to define a uniform interface around __attribute__
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With