arocc
arocc copied to clipboard
Macro expansion which produces defined(X)
This is undefined behavior according to the C standard but both gcc and clang treat it like defined is a function-like macro:
#define FOO_IS_DEFINED defined(FOO)
#define FOO
#if FOO_IS_DEFINED
#error "FOO is defined"
#endif
clang warns test.c:4:5: warning: macro expansion producing 'defined' has undefined behavior [-Wexpansion-to-defined]
Both will evaluate the #if condition to true and will display the "FOO is defined" error message.
aro currently says error: function-like macro 'defined' is not defined