【发布时间】:2021-07-14 08:52:38
【问题描述】:
这让我很困惑: 如果我注释掉从#if 到#endif 的所有内容,程序将在C99 (TinyCC) 中编译。有了条件,它会在 #if 子句之前的行给出预期的错误 ')' (got "0")
#include <stdio.h>
#define IS_BIG_ENDIAN (!*(unsigned char *)&(uint16_t){1})
#if IS_BIG_ENDIAN
struct ieee {
unsigned long sign:1;
unsigned long expo:8;
unsigned long mantissa:23;
};
#else
struct ieee {
unsigned long mantissa:23;
unsigned long expo:8;
unsigned long sign:1;
};
#endif
int main()
{
printf ("%d\n",IS_BIG_ENDIAN);
}
【问题讨论】:
-
This is puzzling me:这是预期行为,一切正常且正确。为什么令人费解? -
没想到...
标签: c c-preprocessor