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 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 |
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
19
20
|
#define LETTER 1 int 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文件要一同编译成一个可运行文件,于是问题 ...
随机推荐
- Gradle使用手册(一):为什么要用Gradle?
原文地址:http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Using-sourceCompatibility-1. ...
- [转]ASP.NET MVC Jquery Validate 表单验证的多种方式介绍
在我们日常开发过程中,前端的表单验证很重要,如果这块处理不当,会出现很多bug .但是如果处理的好,不仅bug会很少,用户体验也会得到很大的提升.在开发过程中我们可以不借助 JS 库,自己去手写 JS ...
- error MSB3027: Could not copy "xxx.dll" to "xxx.dll". Exceeded retry count of 10. Failed.
错误提示内容: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3363,5): error MSB302 ...
- Parallel for loops in .NET C# z
The start index: this is inclusive, i.e. this will be the first index value in the loop The end inde ...
- [JDBC-1] JDBC Base Template
以Statement建立的标准模板: static void template() throws Exception { Connection conn = null; Statement st = ...
- jQuery轻量级京东图片轮播代码等
http://sc.chinaz.com/jiaoben/jiaodiantu.html jQuery轻量级京东图片轮播代码 查看全图点击预览 顶(17)踩(4)报错评论(0)下载地址 更新时间: ...
- JSP的笔记
JSP是一种特殊的Servlet,全称是java server page,属于服务器端语言 就JSP和Servle,HTML比较,三者的优缺点简略如下: Servlet: 缺点:不适合作为HTML的响 ...
- sprintf的缓冲区溢出
sprintf的缓冲区溢出 分类: 技术2010-03-07 15:26 362人阅读 评论(0) 收藏 举报 今天,调试sector的时候遇到一个特奇怪的问题,程序会在取string的c_str() ...
- homework-05 服务器与客户端
首先非常抱歉第三次和第四次作业我没交上来,不想找借口强调原因,但是这两次作业我一定会补上,到时候会@助教.谢谢 回到这次作业! 这次作业邹老师没说博客的格式,所以在这里就没有什么回答问题的东西了.这次 ...
- LinearLayout使用tips
1.LinearLayout有divider属性,可以用来分割layout里面的各个组件 eg: a | b | c 如果c为gone的话,那么第二条线会消失,如果没用divider而使用View画线 ...