c语言之【#ifdef】
|
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 DEBUG cout << "Beginning execution of main()" << endl;#endif return 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 DEBUG cout << "Beginning execution of main()" << endl;#endif return 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 DEBUG cout<< "Beginning execution of main()" << endl;#endif return 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 0 |
|
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
|
#define LETTER 1int main( int argc, char * argv[] ){ char str[20] = "C Language"; 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); } return 0;} |
|
1
|
C LANGUAGE |
|
1
|
#define LETTER 0 |
|
1
|
c language |
c语言之【#ifdef】的更多相关文章
- (五)c语言条件编译#ifdef与#if defined
c语言条件编译#ifdef与#if defined defined NAME是用来判断NAME是否被定义了(被用define定义了). #ifdef NAME == #if defined(NAME) ...
- c语言条件编译#ifdef与#if defined
c语言条件编译#ifdef与#if defined c语言条件编译#ifdef与#if defined 摘自:https://www.cnblogs.com/zhangshenghui/p/566 ...
- 不可或缺 Windows Native (1) - C 语言: hello c
[源码下载] 不可或缺 Windows Native (1) - C 语言: hello c 作者:webabcd 介绍不可或缺 Windows Native 之 C 语言 在 Windows Sto ...
- lua与C/C++交互
Lua设计小巧很容易与C/C++进行交互,下面我们具体讲解C/C++中如何调用lua,而lua中又如何调用C代码. 首先lua和C交互的一个重要的数据结构lua_State,它是进行数据交换的堆栈,按 ...
- C语言的#if #ifdef #ifndef
#if #ifedf #ifndef —般情况下,C语言源程序中的每一行代码.都要参加编译.但有时候出于对程序代码优化的考虑.希望只对其中一部分内容进行编译.此时就需要在程序中加上条件,让编译器只 ...
- C语言#ifdef等宏的妙用
这几个宏是为了进行条件编译.一般情况下,源程序中所有的行都参加编译.但是有时希望对其中一部分内容只在满足一定条件才进行编译,也就是对一部分内容指定编译的条件,这就是“条件编译”.有时,希望当满足某条件 ...
- c语言中的#ifdef和#ifndef
#include "stdio.h"#include "conio.h"#define MAX#define MAXIMUM(x,y) (x>y)?x:y ...
- c语言学习笔记.条件编译.#if,#ifdef,if的区别
最近遇到了,以此做个记录. 条件编译 是C预处理部分的内容. 其判断语句包括 #if #else if #else 以及 #ifdef 和 #endif. 使用 #if (表达式) codes1. ...
- C语言预处理命令之条件编译(#ifdef,#else,#endif,#if等)
转自:http://www.kuqin.com/language/20090806/66164.html 预处理过程扫描源代码,对其进行初步的转换,产生新的源代码提供给编译器.可见预处理过程先于编译器 ...
随机推荐
- wampserver安装配置
按步骤安装--选择指定浏览器-安装成功后显示绿色图标: 打开浏览器:将文件夹移入wampserver安装路径的www文件夹中:找到电脑IP 在手机端访问 IP/文件夹/demo.html即可
- 配置 Oracle 11g侦听器来使用SQL操作ST_Geometry(DLL路径问题)
注:http://resources.arcgis.com/zh-cn/help/main/10.2/index.html#/na/00qn0000001p000000/ (ArcGIS 帮助库) 1 ...
- Googlehack之Github hack
site:aircrk.com smtpsite:aircrk.com smtp @mail.comsite:aircrk.com root passwordsite:aircrk.com smtp ...
- android 动画效果
动画资源 一.分类: (一).概要: 3.0以前,android支持两种动画模式,补间动画(tween animation),帧动画(frame animation),在android ...
- Java暗箱操作之for-each
对于我们常用的ArrayList等容器类,经常需要一个一个遍历里面的元素,从而对各个元素执行对应的操作. 像我代码写多了,通常的做法是用传统的,类似于数组遍历的方法,即在for循环中设置一个int变量 ...
- MVP ComCamp & GCR MVP Openday 2014
今年的MVP Openday与往年不一样,加入了Community Camp环节,即社区大课堂.其主要形式是由MVP作为讲师提供包括Developer和IT Pro方向的课程,地点是在北京国际会议中心 ...
- ORA-12520: TNS:listener could not find available handler for requested type of server
当你碰到ORA-12520错误时,如下所示: 英文错误提示: ORA-12520: TNS:listener could not find available handler for requeste ...
- 基于注解的SpringMVC
相比传统的继承Controller体系中某些类的方式,SpringMVC的注解具有以下优点: 1.Controller不再需要继承某个特定类,只是简单的POJO. 2.请求映射的配置非常方便灵活. 3 ...
- android radiogroup样式(设置切换背景与文字颜色)
main.xml <RadioGroup android:id="@+id/radioGroup1" android:layout_width="wrap_cont ...
- FineReport根据点击次数奇偶性排序之字符型
上一篇文章我们提到了字段为数据型的数据列排序方法,采用的是根据点击次数奇偶性来排序,那如果是字段为字符型,又该如何实现呢? 这里提供的解决思路是通过超级链接来实现升序降序两张模板之间的相互调用,每点击 ...