是否总是在预处理程序之前处理注释? [英] Are comments always processed before the preprocessor?
问题描述
/*
#define FOO
*/
#ifdef FOO
#define BAR "pirate"
#else
#define BAR "ninja"
#endif
int main() { printf(BAR); getchar(); }
在此代码中未定义FOO(Visual Studio 2008)。我假设注释首先被处理,然后是预处理器,然后是代码。是否总是在预处理程序之前处理注释?这是标准的一部分吗?
In this code FOO is not defined (Visual Studio 2008). I assume that comments are processed first, then preprocessor, and then code. Are comments always processed before the preprocessor? Is this part of a standard?
推荐答案
我假设首先处理注释,然后进行预处理,然后进行编码。注释是否总是在预处理程序之前进行处理?
I assume that comments are processed first, then preprocessor, and then code. Are comments always processed before the preprocessor?
排序的工作部分- 被删除评论。在这种情况下,您不必在指令内部添加指令。它仍然像其他评论一样被删除。
Sort of -- part of the preprocessor's job is to remove comments. In this case, it doesn't care that you have the directive inside the comments; it's still removed just like any other comment.
这篇关于是否总是在预处理程序之前处理注释?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!