#if defined 的意思?
在读s3c2440a的test程序,其中option.h文件中有段语句为:
#define LCD_N35 
//#define LCD_L80 
//#define LCD_T35 
//#define LCD_A70 
//#define LCD_VGA1024768
//--end of by Customer--
#if defined(LCD_N35) + defined(LCD_L80) + defined(LCD_T35) + defined(LCD_A70) + defined(LCD_VGA1024768) != 1 
#error Must define only one LCD type 
#endif
其中的粗体不明白什么意思,查找后得知:
若是defined LCD_N35 、 defined LCD_L80 、defined LCD_T35 、 defined LCD_A70 、defined LCD_VGA1024768中有一个定义,则执行#endif后面的语句。
引用百度知道的答案:
因为对于一个大程序而言,我们可能要定义很多常量( 不管是放在源文件还是头文件 ),那么我们有时考虑定义某个常量时,我们就必须返回检查原来此常量是否定义,但这样做很麻烦.if defined宏正是为这种情况提供了解决方案.举个例子,
如下: #define ....
#define ....
........
........
#define a 100
.......
此时,我们要检查a是否定义(假设我们已经记不着这点了),或者我们要给a一个不同的值,就加入如下句子
#if defined a
#undef a
#define a 200
#endif
上述语句检验a是否被定义,如果被定义,则用#undef语句解除定义,并重新定义a为200 同样,检验a是否定义:
#ifndef a //如果a没有被定义
#define a 100
#endif
以上所用的宏中:#undef为解除定义,#ifndef是if not defined的缩写,即如果没有定义。
#if defined 的意思?的更多相关文章
- No result defined for action com.lk.IndexAction and result success
		
意图访问一个 /es/index.action 竟然出现: [SAE ] ERROR [05-11 13:54:32] [http-80-5] com.opensymphony.xwork2.util ...
 - Apache报错信息之Invalid command 'Order', perhaps misspelled or defined by a module not included in the server config
		
今天配置开启Apache虚拟主机时, 然后日志报错提示: Invalid command 'Order', perhaps misspelled or defined by a module not ...
 - _WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)
		
原文地址::http://blog.csdn.net/xiaolongwang2010/article/details/7550505 相关网帖 1.错误找不到WinsdkVer.h----http: ...
 - VC++ : error LNK2005:  ... already defined in *.obj
		
今天写代码遇到了这么一个链接错误:"已经在*.obj中定义". error LNK2005: "void __cdecl ReplaceWstringVar(class ...
 - Target runtime com.genuitec.runtime.generic.jee60 is not defined
		
转载自:http://jingyan.baidu.com/article/d7130635338e3f13fdf47518.html 用eclipse加载别人的工程,报错Target runtime ...
 - TOMCAT-报错The BASEDIR environment variable is not defined correctly
		
<span style="font-size:18px;">The BASEDIR environment variable is not defined correc ...
 - MySql.Data.MySqlClient.MySqlException: Parameter ‘@maxid’ must be defined
		
本文涉及到的mysql知识点: mysql中的if条件语句用法: IF(expr1,expr2,expr3) mysql使用变量(mysql中变量不用事前申明) mysql事务 testcase 为了 ...
 - SQL SERVER中用户定义标量函数(scalar user defined function)的性能问题
		
用户定义函数(UDF)分类 SQL SERVER中的用户定义函数(User Defined Functions 简称UDF)分为标量函数(Scalar-Valued Function)和表值函数(T ...
 - no result defined for action
		
1.no result defined for action .......and result input 或者 no result defined for action .......and ...
 - 解决:Error: JAVA_HOME is not defined correctly
		
问题重现: Error: JAVA_HOME is not defined correctly. We cannot execute :/usr/lib/jvm/java-7-oracle 问题分析: ...
 
随机推荐
- 2014-08-04 BBS主页页面的设计
			
今天是在吾索实习的第19天.这天,开始参照一开始设计的界面原型,真真正正地进行BBS界面的设计.在运用.NET进行界面设计时,发现没有用RP进行界面设计来得容易,很多都要再进行更精细的操作,才能达到原 ...
 - Android中ListView异步加载数据
			
1.主Activity public class MainActivity extends Activity { private ListView listView; private ArrayLis ...
 - 扩展Visual Studio IDE
			
安装visual studio 2012 SDK 下载visual studio SDK. 安装可能遇到的问题 安装时报错:Visual Studio 2012 Install Fails: Prog ...
 - openstack neutron debugs listss
			
Connection to neutron failed: [Errno 111] Connection refused
 - Python读取txt文件
			
Python读取txt文件,有两种方式: (1)逐行读取 data=open("data.txt") line=data.readline() while line: print ...
 - 从一些简单代码实例彻底理解面向对象编程思想|OOP本质是什么?
			
从Rob Pike 的 Google+上的一个推看到了一篇叫<Understanding Object Oriented Programming>的文章,我先把这篇文章简述一下,然后再说说 ...
 - volatile-java关键字
			
volatile的作用: 作为指令关键字,确保本条指令不会因编译器的优化而省略,且要求每次直接读值. 简单地说就是防止编译器对代码进行优化.比如如下程序: XBYTE[2]=0x55; XBYTE[2 ...
 - Android全局变量使用
			
1.通过一个Data.java实例类,能够实现全局数据保存,这里就不多说了,学Java的都知道. 2.Android特有的Application,是应用的入口,执行贯穿整个app执行过程,能够在这个类 ...
 - 屏幕分辨率(QQVGA、QVGA、VGA、XGA、WXGA、WUXGA和WSXGA+)
			
TFT屏幕 TFT ( Thin Film Transistor 薄膜晶体管) ,是有源矩阵类型液晶显示器(AM-LCD)中的一种,TFT在液晶的背部设置特殊光管,能够“主动的”对屏幕上的各个独立的象 ...
 - HDU 4119Isabella's Message2011成都现场赛I题(字符串模拟)
			
Isabella's Message Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...