conditonal complie
来源:互联网 发布:抓小三软件 编辑:程序博客网 时间:2024/05/19 17:04
1. About conditional complie
一般情况下,源程序的所有行都参见编译。但有时候希望对其中一部分内容只在满足一定条件下才进行编译——条件编译(conditional compile).
2. 条件编译语句排版,考虑三种位置
1. 条件编译语句块与函数定义体之间不存在相互嵌套(主要在.h文件)
2. 条件编译语句块嵌套在函数体之外(主要在.c文件)
3. 条件编译语句嵌套在函数体内(主要在.c文件)
注意三种位置的条件编译语句的排版情况!
3. 条件编译指令决定哪些内容编译及不被编译
1
#
空指令,无任何效果
2
#include
包含一个源代码文件
3
#define
定义宏
4
#undef
取消已定义的宏
5
#if
如果给定条件为真,则编译下面代码
6
#ifdef
如果宏已经定义,则编译下面代码
7
#ifndef
如果宏没有定义,则编译下面代码
8
#elif
如果前面的#if给定条件不为真,当前条件为真,则编译下面代码
9
#endif
结束一个#if……#else条件编译块
10
#error
停止编译并显示错误信息
预处理指令以#号开头的代码行.
举例:
#define DEBUG 0
main()
{
#if DEBUG
printf("Debugging\n");
#endif
printf("Running\n");
}
由于程序定义DEBUG宏代表0,所以#if条件为假,不编译后面的代码直到#endif,所以程序直接输出Running。
如果去掉#define语句,效果是一样的。
- conditonal complie
- Conditonal Bayesian Network
- complie kernel
- 【Unity】行为树Conditonal模板
- Redhat ntfs driver complie
- Set Complie Hadoop Path
- hadoop maven complie
- SDL2.0 ubuntu complie
- Python3:re.complie用法
- Android Source Code Complie
- Complie Apache with VC6.0
- servlet批处理程序complie.bat
- complie and install open-iscsi
- gcc complie ffmpeg strange problem
- 自定义指令[directive,link,complie]
- complie---php5.6源码编译
- matlib complie C++ with opencv
- intelligent complie 内存溢出解决
- 雅虎 YQL 接口
- 开发工具使用设置
- Windows7集成SP1微软原版光盘镜像下载大全
- Endnote中英文混排之完美解决
- Qt版本-塔防游戏实现二
- conditonal complie
- 自定义ios控件介绍
- hashcode 和 equals
- VIM配置文件 .vimrc
- TCP/IP编程
- php+js实现图片的上传、裁剪、预览、提交示例
- HDU 1754 I Hate It
- 黑马程序员——完成项目的收获
- 开源虚拟化入门之Linux KVM虚拟化架构