相关疑难解决方法(0)

C预处理器是否首先删除注释或扩展宏?

考虑这个(可怕的,可怕的,没有好的,非常糟糕的)代码结构:

#define foo(x) // commented out debugging code

// Misformatted to not obscure the point
if (a)
foo(a);
bar(a);
Run Code Online (Sandbox Code Playgroud)

我已经看到两个编译器的预处理器在这段代码上生成不同的结果:

if (a)
bar(a);
Run Code Online (Sandbox Code Playgroud)

if (a)
;
bar(a);
Run Code Online (Sandbox Code Playgroud)

显然,对于可移植的代码库来说这是一件坏事.

我的问题:预处理器应该用这个做什么?首先是Elide评论,还是先扩展宏?

c comments c99 c-preprocessor

54
推荐指数
3
解决办法
2万
查看次数

标签 统计

c ×1

c-preprocessor ×1

c99 ×1

comments ×1