#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 问题分析: ...
随机推荐
- [LeetCode] 200. Number of Islands 解题思路
Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surro ...
- zookeeper[5] zookeeper集群配置及伪集群配置
参考:http://zookeeper.apache.org/doc/trunk/zookeeperStarted.html 集群配置: 1.配置文件conf/zoo.cfg,除了单机模式的配置之外, ...
- jQuery扩展与noConflict的用法-小示例
有时我们要用到自己定义的jquery,这时可以通过jQuery扩展来实现该功能 index.html <!DOCTYPE html> <html> <head> & ...
- 安装 Android 运行环境
如果你恰好有一些旧的. 过时的 Android SDK 版本,请务必把所需的包更新至下面提到的版本并安装所有缺少的部分. 安装和配置 SDK 安装最新的 JDK. 使用 brew install an ...
- Ubuntu 12.04 搭建Android开发环境
Ubuntu 12.04 搭建Android开发环境 2013/7/29 Linux环境下搭建Android开发环境 大部分开发人员可能都在Windows下做开发,可能是感觉在Windows下比较方便 ...
- java.lang.OutOfMemoryError: Java heap space错误及处理办法(收集整理、转)
下面是从网上找到的关于堆空间溢出的错误解决的方法: java.lang.OutOfMemoryError: Java heap space ============================== ...
- 飞行模式下不让打开FM
android 判断手机当前是否是飞行模式,在AirplaneModeEnabler中 提供了isAirplaneModeOn方法来判断当前是否是Airplane mode:public stati ...
- web开发小白之路
今天就来谈谈本人从事web开发的一系列白只又白的经历,本人刚开始是从事ios开发的,由于一系列的变故现在变为了web前端开发,不过说来也奇怪,刚开始接触前端时间可以说是彻底蒙圈,各种选择器,各种适配搞 ...
- C#自定义List类
代码如下: using System; using System.Collections.Generic; using System.Linq; using System.Text; namespac ...
- Python 文件I/O (转)
Python 文件I/O 本章只讲述所有基本的的I/O函数,更多函数请参考Python标准文档. 打印到屏幕 最简单的输出方法是用print语句,你可以给它传递零个或多个用逗号隔开的表达式.此函数把你 ...