【发布时间】:2016-10-14 03:15:56
【问题描述】:
根据C11标准,
表单的预处理指令
# 包含“q-char-sequence”换行符
用“分隔符之间的指定序列标识的源文件的全部内容替换该指令。
所以如果我有一个头文件test.h 包含:
#endif
还有一个源文件test.c 包含:
#if 1
#include "test.h"
难道不应该按照标准把test.h的内容替换原地通过预处理阶段吗?
但我不能用 clang 做到这一点,它说:
In file included from test.c:2:
./test.h:1:2: error: #endif without #if
#endif
^
test.c:1:2: error: unterminated conditional directive
#if 1
^
2 errors generated.
那么标准规定的行为是什么?
【问题讨论】:
标签: c++ c c-preprocessor c11 preprocessor-directive