本文介绍了预处理程序指令#if和#ifdef之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下两个预处理器控制语句之间有什么区别(如果有)。
What is the difference (if any) between the two following preprocessor control statements.
#if
和
#ifdef
推荐答案
您可以这样做: p>
You can demonstrate the difference by doing:
#define FOO 0
#if FOO
// won't compile this
#endif
#ifdef FOO
// will compile this
#endif
#if
检查符号的值,而 #ifdef
检查符号符号的存在(无论其值如何)。
#if
checks for the value of the symbol, while #ifdef
checks the existence of the symbol (regardless of its value).
这篇关于预处理程序指令#if和#ifdef之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!