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 预处理过程扫描源代码,对其进行初步的转换,产生新的源代码提供给编译器.可见预处理过程先于编译器 ...
随机推荐
- Dog_Hybird的诞生
起因 开玩笑说“iOS搞不动了”,另外一方面iOS组的哥哥们给力,少一个我也妥妥的.又听闻web前端组来了一个不得了的人物,“老司机,带带我”这种机会不能错过,1个多月前就申请转web前端了.开始是苦 ...
- 心无旁骛,向死而生:WGDC2016给创企上的一堂课
"这是最好的时代,也是最坏的时代:这是希望的春天,也是失望的冬天." ------狄更斯 WGDC2016落幕已经一月有余,我仍然记得会议结束后,穿过高大宽敞的国家会议中心大厅,走 ...
- iOS字体
- iOS 开发之路(WKWebView内嵌HTML5之图片上传) 五
HTML5页面的图片上传功能在iOS端的实现. 首先,页面上用的是plupload组件,在wkwebview上存在两个坑需要修复才能正常使用. 问题:在webview上点击选择照片/相机拍摄,就会出现 ...
- 解决PKIX:unable to find valid certification path to requested target 的问题
这两天在twitter服务器上忽然遇到这样的异常: e: sun.security.validator.ValidatorException: PKIX path building failed: s ...
- java HelloWorld 提示“错误: 找不到或无法加载主类 HelloWorld“解决方案
在检查环境变量等前提工作准确无误后,注意要配好CLASSPATH,仍然报“错误: 找不到或无法加载主类 HelloWorld“. 本人工程目录:mygs-maven/src/main/java/hel ...
- 分布式搜索引擎Elasticsearch的查询与过滤
一.写入 先来一个简单的官方例子,插入的参数为-XPUT,插入一条记录. curl -XPUT 'http://localhost:9200/test/users/1' -d '{ "use ...
- ORA-01033因误删表空间文件导致的解决方案
该类问题通常是由于表空间操作不当引起的.解决方法: SQL*Plus无法连接,显示以下错误:ORA-01033:ORACLE initialization or shutdown in progres ...
- 安装Ubuntu的那些事儿(续)
由于我的第一篇Blog并没有给出完全解决进Ubuntu系统时显卡所造成的问题,至于那个装显卡驱动的方法本人也没有去做,感兴趣的朋友可以在网上教程试一试. 至于我的那个在高系选项中进行配置也不是好的方法 ...
- 如何捕捉并分析SIGSEGV的现场
linux下程序对SIGSEGV信号的默认处理方式是产生coredump并终止程序,可以参考man 7 signal Signal Value Action Comment ───────────── ...