#if /#endif 预处理指令
#if /#endif preprocessing directives
我应该总是使用#if
指令和#endif
吗?
- 如果是 - 如果我只使用
#if
会有什么问题? - 如果没有 - 当我只使用
#if
时,以及当组合#if
/#else
时?
谢谢。
1.If yes - what could be a problem if I only use #if?
正如其他人所提到的,如果您只使用 #if 并且与 #endif 不匹配,预处理器将失败,并显示为编译器错误。
2.If no - why I use only #if,and when combination #if/#else?
即使在 #if/#else 的情况下,最后也应该有一个 #endif。否则它将不起作用。您可以自己尝试并检查。
除了检查和定义宏之外,它们最常用于条件编译。请在下面找到一些相关链接(基本级别):
http://gcc.gnu.org/onlinedocs/cpp/Ifdef.html
http://en.wikipedia.org/wiki/C_preprocessorhttp://www.phanderson.com/C/preprocess.html
如果您没有匹配的#endif
,(或#else
... #endif
) 您的代码将无法编译。
是的。
如果没有#endif
预处理器将无法知道#if
块的结束。
相关文章:
- 错误:无效的预处理指令 #i 的意思是 #if?
- C++预处理会生成变量成员、资源库和映射
- 使用预处理指令检查是否包含标头?
- 预处理的 C/C++ 文件是否特定于计算机?
- 使用 GCC 对 C 文件进行部分预处理(不删除 "define" 指令)
- 在 CPLEX 中求解线性规划,无需剪切和预处理
- CPP -D 选项,用于预处理 Fortran 代码
- 错误:粘贴"tmp_UINT"和"+"未提供有效的预处理令牌
- 任务计划程序库的预处理不起作用 - 多定义错误
- Eclipse 问题 - 编译期间不考虑 .c 和 .cpp 文件中定义的预处理
- 使用python预处理后,C++(opencv)中的垫子类型数据与image_to_array相同
- Howo 使用 cl 预处理为 masm 组装生成一个单独的文件
- 我有一个预处理的 C/C++ 源文件 (cacti.i).如何从这个 .i 文件生成可执行二进制文件,以便我可以像 ./
- 如何使用Visual Studio C/C++编译器(cl.exe)来预处理我的objective-C代码
- 是具有预处理前分支实现的结构违反ODR
- 与不完整的Cholesky预处理的共轭梯度返回特征库的意外错误
- #if /#endif 预处理指令
- 编写c++正则表达式以匹配#include预处理指令
- g++错误:预处理指令#INCLUDE无效
- 包含预处理指令的多行宏语句