可以为#define 分配defined 的结果吗?

Can a #define be assigned the result of defined?

下面代码的结果是用C还是C++定义的?

#define FOO
#define BAR defined(FOO)
#if BAR
    int x = 1;
#else
    int x = 2;
#endif

使用defined作为条件指令的扩展被认为是未定义的行为

If the token defined is generated as a result of this replacement process or use of the defined unary operator does not match one of the two specified forms prior to macro replacement, the behavior is undefined.

None of these macro names, nor the identifier defined, shall be the subject of a #define or a #undef preprocessing directive.

If the defined operator appears as a result of a macro expansion, the C standard says the behavior is undefined. GNU cpp treats it as a genuine defined operator and evaluates it normally. It will warn wherever your code uses this feature if you use the command-line option ‘-pedantic’, since other compilers may handle it differently.