9.5.4 Conditional compilation directives

E4CAB753-B41A-48FE-A387-D60B9FCDABC5.PNG 立即下载
9.5.4 Conditional compilation directives
The conditional compilation directives are used to conditionally include or
exclude portions of a source file.
pp-conditional::
pp-if-section pp-elif-sectionsopt pp-else-sectionopt pp-endif
pp-if-section::
whitespaceopt # whitespaceopt if whitespace pp-expression pp-new-line
conditional-sectionopt
pp-elif-sections::
pp-elif-section
pp-elif-sections pp-elif-section
pp-elif-section::
whitespaceopt # whitespaceopt elif whitespace pp-expression pp-new-line
conditional-sectionopt
pp-else-section::
whitespaceopt # whitespaceopt else pp-new-line conditional-sectionopt
pp-endif::
whitespaceopt # whitespaceopt endif pp-new-line
conditional-section::
input-section
skipped-section
skipped-section::
skipped-section-part
skipped-section skipped-section-part
skipped-section-part::
skipped-charactersopt new-line
pp-directive
skipped-characters::
whitespaceopt not-number-sign input-charactersopt
not-number-sign::
Any input-character except #
[Note: As indicated by the syntax, conditional compilation directives must
be written as sets consisting of, in
order, an #if directive, zero or more #elif directives, zero or one #else
directive, and an #endif directive.
Between the directives are conditional sections of source code. Each
section is controlled by the immediately
preceding directive. A conditional section may itself contain nested
conditional compilation directives provided
these directives form complete sets. end note]
A pp-conditional selects at most one of the contained conditional-sections
for normal lexical processing:
C# LANGUAGE SPECIFICATION
66
?The pp-expressions of the #if and #elif directives are evaluated in order
until one yields true. If an
expression yields true, the conditional-section of the corresponding
directive is selected.
?If all pp-expressions yield false, and if an #else directive is present,
the conditional-section of the #else
directive is selected.
?Otherwise, no conditional-section is selected.
The selected conditional-section, if any, is processed as a normal
input-section: the source code contained in the
section must adhere to the lexical grammar; tokens are generated from the
source code in the section; and preprocessing
directives in the section have the prescribed effects.
The remaining conditional-sections, if any, are processed as
skipped-sections: except for pre-processing
directives, the source code in the section need not adhere to the lexical
grammar; no tokens are generated from
the source code in the section; and pre-processing directives in the
section must be lexically correct but are not
otherwise processed. Within a conditional-section that is being processed
as a skipped-section, any nested
conditional-sections (contained in nested #if...#endif and
#region...#endregion constructs) are also
processed as skipped-sections.
[Example: The following example illustrates how conditional compilation
directives can nest:
#define Debug // Debugging on
#undef Trace // Tracing off
class PurchaseTransaction
{
void Commit() {
#if Debug
CheckConsistency();
#if Trace
WriteToLog(this.ToString());
#endif
#endif
CommitHelper();
}
.
}
Except for pre-processing directives, skipped source code is not subject to
lexical analysis. For example, the
following is valid despite the unterminated comment in the #else section:
#define Debug // Debugging on
class PurchaseTransaction
{
void Commit() {
#if Debug
CheckConsistency();
#else
/* Do something else
#endif
}
.
}
Note, however, that pre-processing directives are required to be lexically
correct even in skipped sections of
source code.
Pre-processing directives are not processed when they appear inside
multi-line input elements. For example, the
program:
Chapter 9 Lexical structure
67
class Hello
{
static void Main() {
System.Console.WriteLine(@"hello,
#if Debug
world
#else
Nebraska
#endif
");
}
}
results in the output:
hello,
#if Debug
world
#else
Nebraska
#endif
In peculiar cases, the set of pre-processing directives that is processed
might depend on the evaluation of the ppexpression.
The example:
#if X
/*
#else
/* */ class Q { }
#endif
always produces the same token stream (class Q { }), regardless of whether
or not X is defined. If X is defined,
the only processed directives are #if and #endif, due to the multi-line
comment. If X is undefined, then three
directives (#if, #else, #endif) are part of the directive set. end example]
ASTM D4583-21(2025).pdf ASTM D4583-21(2025) 立即下载

相关推荐

Streaming-Speech-Recognition-Privacy-Boundary-Auditor-v1.0-原创源码与文档.zip

原创 JavaScript 工程工具合集条目,包含完整源码、README、MIT License、原创与授权声明、3 项自动化测试、可复现合成示例、离线 HTML/JSON/SVG 报告和 1080×720 真实运行效果图。Node.js 18+ 可直接运行,零第三方运行依赖,适合开发者用于数据校验、工程审计、容量规划与交付复核。热点仅作为需求信号,不含榜单项目源码、模型权重、品牌素材或官方截图。

使用Axis2报"An error occurred while completing process -java.lang.reflect.InvocationTargetException"处理...

我查了很多有关处理这方面错误的文章,很多给出的处理方案并不能解决我的问题,比如典型的方案如下: 从AXIS2的LIB库中复制"geronimo-stax-api_1.0_spec-1.0.1.jar"和下载"backport-util-concurrent-3.1.jar"文件到Codegen的lib目录中,同时修改plugin.xml文件,添加 <library name="lib...

iteye_2022的博客 266

技术转移机构如何高效评估技术成果的价值?.docx

技术转移机构如何高效评估技术成果的价值?

问题一

Server Error in '/' Application. Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific er

KingcinLee的博客 802

使用Axis2 插件 报错"An error occurred while completing process -java.lang.reflect.InvocationTargetExceptio...

参考http://blog.csdn.net/sunitjy/article/details/6793654 转载于:https://www.cnblogs.com/noosc/p/4726520.html

weixin_30586257的博客 318

Error-unterminated conditional directive

比如A要使用B,B又使用了A,可以在A.h中声明B,然后在A.cpp中包含B的头文件B.h,不过要注意代码逻辑不要循环递归调用了…在有#endif的情况下还报错,是头文件互相包含的问题。解决头文件互相包含的需求。可能是没写#endif。

weixin_39406189的博客 1093

sas mysql乱码_SAS 数据步 常见错误汇总之1-上

来自http://hi.baidu.com/רҵͳ��ʦ/blog/item/7dd299faf7b7ac1e6c22eb72.htmlSAS的DEBUG方面的内容比较少,现在我将网上的一些有关DEBUG的文章找了一些,然后整理了一下。本文主要讲了SASdebug的态度。本次也主要是讲一下态度,虽然有点像政治课,但是态度真的非常重要,编程的时候心态一定要放宽,不要太乐观地认为肯定没问题,一定要细心...

weixin_39628594的博客 801

“an error occurred while processing this directive”的解决方法

最近帮一客户用dedecms做站,却在前台显示“an error occurred while processing this directive”的错误提示,搜索了这段提示,发现很多人遇到这个问题,而且不仅是dedecms遇到这个问题,其它的CMS也有这问题。         这说明并不是CMS的问题,而是模板的问题,搜索了很多资料,没有找到具体的原因。今天仔细检查,终于找到了原因。

№快乐因你♂ 2万+

error: unterminated conditional directive

#ifndef *** #define *** #endif 出现错误的原因是结尾没有 #endif。

HBX_1024的博客 3282

PL/SQL Conditional Compilation

该特性与C语言的类似。从Oracle 9.2.0.6开始被引入,9.2.0.6默认关闭该特性,可以通过一个参数打开。10gR1默认是打开,可以关闭。10gR2或以上默认打开,不可以关闭。常用于以下场景: 代码使用Oracle某新特性实现某个需求;为了兼容老版本Oracle,需要用另一个方法实现。在编译时,可以针对Oracle版本,选择性的编译。在开发时,打开Tracing, 生产服务器上关闭

chncaesar的专栏 1121

unterminated conditional directive

keil中编写预编译语句出现:unterminated conditional directive(条件语句没有结束) 原因:结尾缺少#endif

EXC_Twisted_Fate的博客 7679

科技园区如何精准招引高潜力科创项目并提升招商效率?.docx

科技园区如何精准招引高潜力科创项目并提升招商效率?

高校如何提升科研项目评价的科学性与效率?.docx

科易网基于40亿+科创知识图谱数据库,深度探索AI技术在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,研究科技创新领域的AI+数智化解决方案,推动科技创新与产业创新智能化发展。

国央企如何优化重大科技项目的决策与资源分配?.docx

科易网基于40亿+科创知识图谱数据库,深度探索AI技术在技术转移、成果转化、技术经纪、知识产权、产业创新、科技招商等垂直领域的多样化应用场景,研究科技创新领域的AI+数智化解决方案,推动科技创新与产业创新智能化发展。

上一篇: 9.5.6 Region control
下一篇: 9.5.5 Diagnostic directives
masterall
博客等级 码龄22年 17粉丝 557原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值