ifndef/define/endif 的作用
转载自百度百科 ,感谢度娘
|
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 DEBUGcout << "Beginning execution of main()" << endl;#endifreturn 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 DEBUGcout << "Beginning execution of main()" << endl;#endifreturn 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 DEBUGcout << "Beginning execution of main()" << endl;#endifreturn 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 |
|
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
19
20
|
#define LETTER 1int main(int argc,char *argv[]){ char str[20] = "CLanguage"; 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); } return0;} |
|
1
|
CLANGUAGE |
|
1
|
#define LETTER 0 |
|
1
|
clanguage |
ifndef/define/endif 的作用的更多相关文章
- 头文件里面的ifndef /define/endif的作用
c,c++里面,头文件里面的ifndef /define/endif的作用 今天和宿舍同学讨论一个小程序,发现有点地方不大懂······ 是关于头文件里面的一些地方: 例如:要编写头文件test.h ...
- 头文件中的#ifndef/#define/#endif 的作用
在一个大的软件工程里面,可能会有多个文件同时包含一个头文件,当这些文件编译链接成一个可执行文件时,就会出现大量重定义的错误.在头文件中实用#ifndef #define #endif能避免头文件的重定 ...
- 头文件中ifndef/define/endif的作用以及#pragma once使用
例如:要编写头文件test.h 在头文件开头写上两行: #ifndef _TEST_H #define _TEST_H//一般是文件名的大写 ············ ············ 头文件 ...
- C/C++头文件使用 #ifndef #define #endif 的原因
背景 在编译的时候,出现"redefine"的错误,最后检查才发现对应的头文件没有写正确的预编译信息: #ifndef _HeadFileName_H #define _HeadF ...
- #ifndef, #define, #endif 作用
#ifndef, #define, #endif 作用 https://www.cnblogs.com/challenger-vip/p/3386819.html
- ifndef/define/endif 和 #ifdef 、#if 作用和用法
为了能简单的看看某些linux内核源码,复习了一下c语音,今天汇总了一下关于宏定义的相关内容: 一.ifndef/define/endif用法: .h文件,如下: #ifndef XX_H #defi ...
- #ifndef, #define, #endif三者的作用
#ifndef, #define, #endif 作用 #ifndef 它是if not define 的简写,是宏定义的一种,实际上确切的说,这应该是预处理功能三种(宏定义.文件包含.条件编译) ...
- ifndef/define/endif作用和用法
问题:ifndef/define/endif”主要目的是防止头文件的重复包含和编译,偶只知道这个概念不懂的是怎么个用法,和为什么要用它~~高手请指点一下~~谢谢~~~!!! ------------- ...
- C++ ifndef /define/ endif 作用和用法
ifndef/define/endif”主要目的是防止头文件的重复包含和编译 比如你有两个C文件,这两个C文件都include了同一个头文件.而编译时,这两个C文件要一同编译成一个可运行文件,于是问题 ...
随机推荐
- 静态Web开发 DOM
四章 Dom 1节dom中的顶级对象 dom(文档对象模型)js最终是要操作html页面,让html变成DHtml,而操作Html页面就要用到DOMDOM可以吧Html页面模拟成一个对象,如果js只是 ...
- 什么是MBeanServer
什么是MBeanServer MBeanServer是一个包含所有注册MBean的仓库.它是JMX代理层的核心.JMX1.0规范提供一个接口叫 javax.management.MBeanServer ...
- HDU 4614-Vases and Flowers(线段树区间更新)
题意: n个花瓶(0-n-1) 现有两个操作, 操作1 给a,f 从a位置开始向后连续插f个花(一个花瓶插一个)若当前花瓶有花则向后找,直到n-1位置如果还有多余的花则丢掉求查完花的第一和最后一个位置 ...
- java 实现死锁
package 线程安全的讨论; class DThread implements Runnable { private Object o1=null; private Object o2=null; ...
- TCP 滑动窗口的简介
TCP 滑动窗口的简介 POSTED BY ADMIN ON AUG 1, 2012 IN FLOWS34ARTICLES | 0 COMMENTS TCP的滑动窗口主要有两个作用,一是提供TCP的可 ...
- java web工程发布以及解决tomcat闪退
1.tomcat闪退 a.环境变量错误 startup.bat最后假如PAUSE进入调试状态,双击startup.bat,可以看到错误,根据错误提示设置相应的环境变量,JAVA_HOME等. b.ec ...
- SQL Server 用表中已有数据造数据
从表中选择数据再插入到表中(select XXX into 与insert into XXX select的结合) 在做性能测试时需要大量的业务数据.完全从画面造数据比较费时间,使用SQL文批量插入数 ...
- Polymorphism
多态定义(百度百科):多态(Polymorphism)按字面的意思就是“多种状态”.在面向对象语言中,接口的多种不同的实现方式即为多态.引用Charlie Calverts对多态的描述 ——多态性是允 ...
- [读书笔记]了不起的node.js(二)
这周做项目做得比较散(应该说一直都是这样),总结就依据不同情境双开吧-这篇记录的是关于node的学习总结,而下一篇是做项目学到的web前端的知识. 1.HTTP篇 node的HTTP模块在第一篇时接触 ...
- MAC OS安装wget
MAC下没有wget工具,不习惯curl,使用起来还是很不方便的.下载了一个wget源码吧,编译安装.sudo curl -O http://ftp.gnu.org/gnu/wget/wget-1.1 ...