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 预处理过程扫描源代码,对其进行初步的转换,产生新的源代码提供给编译器.可见预处理过程先于编译器 ...
随机推荐
- 64位win7+vs2010编译.net3.5以前的版本问题
一般编译会出现 1.“ResGen.exe”已退出,代码为2 问题处理 2.“错误 2 “LC.exe”已退出,代码为 -1. NBGIS.MainGIS” 3.“未能加载文件或程序集“ESRI.Ar ...
- sharepoint
<script> $("#sideNavBox").css('display','none'); $("#contentBox").css('mar ...
- JAVA匿名内部类
首先定义一个抽象类Computer public abstract class Computer { //抽象类是不可以常见对象的 int a=1; public abstract void onli ...
- PHP服务缓存优化之ZendOpcache、xcache、eAccelerator
PHP服务缓存优化原理 Nginx 根据扩展名或者过滤规则将PHP程序请求传递给解析PHP的FCGI,也就是php-fpm进程 缓存操作码(opcode) Opcode,PHP编译后的中间文件,缓存给 ...
- linux快速删除海量文件
首先创建一个临时目录: /rubbish rsync --delete-before -a -H -v --progress --stats /rubbish /111 /111为目的目录 选项说明: ...
- 【Linux学习】如何了解一个陌生的命令?
如何了解一个陌生的命令? 有一些命令可以用来了解某个命令本身的情况,比如这个命令的绝对路径. $which ls which 在默认路径中搜索命令,返回该命令的绝对路径. $whereis ls wh ...
- 【转】关于Java的Daemon线程的理解
原文地址:http://www.cnblogs.com/ChrisWang/archive/2009/11/28/1612815.html 关于Java的Daemon线程的理解 网上对Java的Dae ...
- linux黄金命令[积累中]
/usr/share/fonts/ fc-cache -v -f sudo chmod 777 ./* sudo mkfontscale sudo mkfontdir sudo fc-cache -f ...
- 012.对netmap API的解读
一.简要说明: 1.netmap API主要为两个头文件netmap.h 和netmap_user.h ,当解压下载好的netmap程序后,在./netmap/sys/net/目录下,本文主要对这两个 ...
- ANDROID开发中注意不同手机CPU架构对SO文件的不同需求。
如果没有对应于手机的SO文件,那么在调用第三方SDK时,会经常发生莫明其妙的错误.所以了解你调式或开发的目的手机CPU架构是很有必要的.