#include<stdio.h>
#define NUM 10
main()
{
#ifdef NUM
printf("compilation succesfull");
#endif
}
上面的代码编译得很好并且在执行时打印
编译成功,但是如果我在 main()
中的第一条语句之前删除了一个空行
它给出了一个错误。 IE。程序中出现“stray #”和许多其他错误。
#include<stdio.h>
#define NUM 10
main()
{ #ifdef NUM
printf("compilation succesfull");
#endif
}
谁能帮帮我?
最佳答案
预处理器语句需要独占一行。因此,您不能将它与 {
或任何不属于该语句的其他内容放在同一行。
关于条件编译错误与宏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30352580/