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 预处理过程扫描源代码,对其进行初步的转换,产生新的源代码提供给编译器.可见预处理过程先于编译器 ...
随机推荐
- input checkbox 扩大点击范围
<div style="width:100%;height:100px;"><input type="checkbox" onclick=&q ...
- js的url解析函数封装
在实际开发中,有些通过get方式与后台交换数据的时候,需要用到的数据在url中,因此就需要我们来获取到url中有用的信息,下面封装的函数已经可以将url解析的很彻底了,可以拿来直接用的: functi ...
- iOS tableView右滑显示选择
如何使用UITableViewRowAction实现右滑选择呢? 1.在iOS8以前,我们实现tableview中滑动显示删除,置顶,更多等等的按钮时,都需要自己去实现,在iOS8中系统已经写好了,只 ...
- iOS之应用发布中的一些细节
Bundle identifier Xcode中 Target -> General中的bundle identifier ; info.plist中的Bundle identifier; 证书 ...
- Git remote 修改源
Git remote 修改源 git commit -m "Change repo." # 先把所有为保存的修改打包为一个commit git remote remove orig ...
- 如何获取ios 设备名字 model
由于需要获取设备名字,在网上找了一些方法,发现能够解决问题,但是需要做一个匹配,然后设备年年都会出新款,而且设备的种类又很多,所以在获取设备信息后我又做了一个操作,--->我在google上找到 ...
- IOS开发基础知识--碎片38
1:FCUUID获取设备标识的运用 a:作者 githun地址 https://github.com/fabiocaccamo/FCUUID 因为里面还用到作者的另外一个类UICKeyChainSto ...
- Android Studio导入Vitamio多媒体开发框架
PS:这篇笔记用于解决Android Studio导入Vitamio框架的问题.官网给出的相关说明过于简单,故整理这篇文章,希望能帮助到像我一样遇到这个问题的朋友. 开发学习建议参考农民伯伯的博客中的 ...
- Android framework编译出来的jar包classes.jar的位置
在源码环境下编译 Android framework编译出来的jar包classes.jar的位置 out/target/common/obj/JAVA_LIBRARIES/framework_in ...
- Java打印九九乘法表
package com.czgo; /** * 九九乘法表 * * @author AlanLee * */ public class Print99 { public static void mai ...