#if预处理器指令可以嵌套在C ++中吗? [英] Can #if pre-processor directives be nested in C++?
本文介绍了#if预处理器指令可以嵌套在C ++中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对c ++中的预处理器指令有疑问:
I have a question about Pre-processor directives in c++:
例如:
#ifndef QUESTION
//some code here
#ifndef QUESTION
//some code here
#endif
#endif
我们可以使用以这种方式,并且C ++编译器能以正确的方式匹配 ifndef
和 endif
吗?
Can we use it in this way, and can the C++ compiler match the ifndef
and endif
in the right way?
推荐答案
是的,我们可以。 #endif
语句与上一个 #if
#ifdef
或 #endif
。
Yes, we can. The #endif
statement matches to the previous #if
#ifdef
or #ifndef
etc for which there hasn't been a corresponding #endif
.
例如
#if ----------|
#if -----| |
#endif ---| |
#endif --------|
这篇关于#if预处理器指令可以嵌套在C ++中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文