ifndef/define/endif 的作用
转载自百度百科 ,感谢度娘
|
1
2
3
|
#ifdef语句1//程序2#endif |
|
1
2
3
4
5
6
7
8
9
|
#include <iostream>using namespace std;int main(int argc, char *argv[]){#ifdef DEBUGcout << "Beginning execution of main()" << endl;#endifreturn 0;} |
|
1
|
Press any key to continue |
|
1
2
3
4
5
6
7
8
9
10
|
#include <iostream>using namespace std;#define DEBUGint main(int argc, char *argv[]){#ifdef DEBUGcout << "Beginning execution of main()" << endl;#endifreturn 0;} |
|
1
2
|
Beginning execution of main()Press any key to continue |
|
1
2
3
|
#define DEBUG#ifdef DEBUG#endif |
|
1
2
3
4
5
6
7
8
9
|
#include <iostream>#include "head.h"int main(int argc,char *argv[]){#ifdef DEBUGcout << "Beginning execution of main()" << endl;#endifreturn 0;} |
|
1
2
|
Beginning execution of main()Press any key to continue |
|
1
2
3
4
5
|
#ifdef 标识符//程序段1#else//程序段2#endif |
|
1
2
3
|
#ifdef 标识符//程序段1#endif |
|
1
2
3
4
5
|
#ifdef WINDOWS#define MYTYPE long#else#define MYTYPE float#endif |
|
1
|
#define WINDOWS |
|
1
|
#define MYTYPE long |
|
1
|
#define WINDOWS |
|
1
2
3
|
#ifdef DEBUGprint("device_open(%p)\n",file);#endif |
|
1
|
#define DEBUG |
|
1
2
3
4
5
|
#ifndef 标识符//程序段1#else//程序段2#endif |
|
1
2
3
4
5
|
#if 表达式//程序段1#else//程序段2#endif |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#define LETTER 1int main(int argc,char *argv[]){ char str[20] = "CLanguage"; char c; int i=0; while((c = str[i]) != '\0') { i++; #if LETTER if(c>='a'&&c<='z') c=c-32; #else if(c>='A'&&c<='Z') c=c+32; #endif printf("%c",c); } return0;} |
|
1
|
CLANGUAGE |
|
1
|
#define LETTER 0 |
|
1
|
clanguage |
ifndef/define/endif 的作用的更多相关文章
- 头文件里面的ifndef /define/endif的作用
c,c++里面,头文件里面的ifndef /define/endif的作用 今天和宿舍同学讨论一个小程序,发现有点地方不大懂······ 是关于头文件里面的一些地方: 例如:要编写头文件test.h ...
- 头文件中的#ifndef/#define/#endif 的作用
在一个大的软件工程里面,可能会有多个文件同时包含一个头文件,当这些文件编译链接成一个可执行文件时,就会出现大量重定义的错误.在头文件中实用#ifndef #define #endif能避免头文件的重定 ...
- 头文件中ifndef/define/endif的作用以及#pragma once使用
例如:要编写头文件test.h 在头文件开头写上两行: #ifndef _TEST_H #define _TEST_H//一般是文件名的大写 ············ ············ 头文件 ...
- C/C++头文件使用 #ifndef #define #endif 的原因
背景 在编译的时候,出现"redefine"的错误,最后检查才发现对应的头文件没有写正确的预编译信息: #ifndef _HeadFileName_H #define _HeadF ...
- #ifndef, #define, #endif 作用
#ifndef, #define, #endif 作用 https://www.cnblogs.com/challenger-vip/p/3386819.html
- ifndef/define/endif 和 #ifdef 、#if 作用和用法
为了能简单的看看某些linux内核源码,复习了一下c语音,今天汇总了一下关于宏定义的相关内容: 一.ifndef/define/endif用法: .h文件,如下: #ifndef XX_H #defi ...
- #ifndef, #define, #endif三者的作用
#ifndef, #define, #endif 作用 #ifndef 它是if not define 的简写,是宏定义的一种,实际上确切的说,这应该是预处理功能三种(宏定义.文件包含.条件编译) ...
- ifndef/define/endif作用和用法
问题:ifndef/define/endif”主要目的是防止头文件的重复包含和编译,偶只知道这个概念不懂的是怎么个用法,和为什么要用它~~高手请指点一下~~谢谢~~~!!! ------------- ...
- C++ ifndef /define/ endif 作用和用法
ifndef/define/endif”主要目的是防止头文件的重复包含和编译 比如你有两个C文件,这两个C文件都include了同一个头文件.而编译时,这两个C文件要一同编译成一个可运行文件,于是问题 ...
随机推荐
- 《深入Java虚拟机学习笔记》- 第7章 类型的生命周期/对象在JVM中的生命周期
一.类型生命周期的开始 如图所示 初始化时机 所有Java虚拟机实现必须在每个类或接口首次主动使用时初始化: 以下几种情形符合主动使用的要求: 当创建某个类的新实例时(或者通过在字节码中执行new指令 ...
- Algorithm for Maximum Subsequence Sum z
MSS(Array[],N)//Where N is the number of elements in array { sum=; //current sum max-sum=;//Maximum ...
- SDUT 3257 Cube Number 简单数学
把所有数的立方因子除去,那么一个数可以和它组成立方的数是确定的,统计就行 #include <cstdio> #include <iostream> #include < ...
- 【暑假】[实用数据结构]UVAlive 3026 Period
UVAlive 3026 Period 题目: Period Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld ...
- Debug Assertion Failed!
问题并没有解决..... 不知道怎么回事,先都没有这样的情况... VC++调程序出现如下错误: Debug Assertion Failed! Program: D:wyuS ...
- U盘安装CentOS 6.5注意事项
这两天新到一批机器,需要安装系统.买的机器没有光驱,只能使用U盘或者网络安装.为了方便,我使用UltraISO对U盘进行刻录制作了启动盘.一切都是那么顺利,安装完成了,没出现什么问题(毕竟 ...
- Linux江湖01:玩转Linux系统的方法论 (转载)
http://www.blogjava.net/youxia/archive/2015/01/08/linux001.html 2014年上半年,我是在写RCP系列.然后,由于要准备研究生毕业论文和答 ...
- 自定义实现MPVolumeView音量控件
http://blog.csdn.net/theonezh/article/details/8158420 http://www.cnblogs.com/cate/ios/ http://www.cn ...
- 《数据通信与网络》笔记--QoS
QoS(Quality of Service)服务质量,是网络的一种安全机制, 是用来解决网络延迟和阻塞等问题的一种技术. 1.QoS参数 衡量服务质量QoS的参数主要包括: 端到端延迟(Delay) ...
- 【Stage3D学习笔记续】山寨Starling(八):核心优化(批处理)的实现
批处理是使GPU进行高效绘制的一种技术手段,也是整个渲染流程中最核心的技术,到目前为止我们并没有使用到这种技术手段,下面我们看看我们现在的渲染机制. 先想一想我们最开始是怎么向GPU绘制一幅图像的,可 ...