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 DEBUG 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
|
#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 DEBUG print ( "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 1 int 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 预处理过程扫描源代码,对其进行初步的转换,产生新的源代码提供给编译器.可见预处理过程先于编译器 ...
随机推荐
- iOS使用Zbar扫描二维码
iOS使用Zbar扫描二维码 标签(空格分隔):二维码扫描 iOS Zbar64位 正文: 首先下载一个支持64位系统的ZbarSDK的包,保存在了我的云盘里,地址:ZbarSDK 把文件拖到工程里面 ...
- iOS 10 推送的简单使用
首先介绍一下本文涉及到UserNotifications的几个主要类. 其中 [1]UNNotification主要是作为通知delegate方法的参数使用.包含UNNotificationReque ...
- You must use the Role Management Tool to install or configure Microsoft .NET Framework 3.5 SP1
今天在Windows Server 2008 下安装SQL SERVER 2008时,碰到如下错误: You must use the Role Management Tool to install ...
- StringUtils工具类
StringUtils源码,使用的是commons-lang3-3.1包.下载地址 http://commons.apache.org/lang/download_lang.cgi 以下是String ...
- Python学习笔记1-数据类型
数据类型: float — 浮点数可以精确到小数点后面15位 int — 整型可以无限大 bool — 非零为true,零为false list — 列表 Float/Int: 运算符: / — 浮点 ...
- windows系统快捷操作の高级篇
上次介绍了windows系统上几个比较好用的软件和系统快捷键,虽然有些很方便,但是毕竟还是太少了,而且无法自定义专属于自己的快捷键.所以我写了这么一篇教程,主要介绍两个神器:windows平台上的au ...
- Linux 服务器模型小结
当我们用socket进行编程的时候,细节上都是选择一个AF_LOCAL,AF_INET再根据相应的类型填充地址,其实根据通信需求,有几种简单的服务模型可供选用,掌握了这些框架再结合socket高度的抽 ...
- Linux 多线程可重入函数
Reentrant和Thread-safe 在单线程程序中,整个程序都是顺序执行的,一个函数在同一时刻只能被一个函数调用,但在多线程中,由于并发性,一个函数可能同时被多个函数调用,此时这个函数就成了临 ...
- x01.Weiqi.8: 一点改进
原来的代码全部删除,进行了深层次重构,得其意而忘其言.得意之处有二: 1.关于显示 以 StoneSize 属性为依托,在 set 中加了一句:Width = Height = m_StoneSize ...
- android break 与 return 的区别
break 的含义是中断,return 的含义是结束整个方法的执行. 区别. public static void main(String agrs[]){ int i; for(i=0;i<1 ...