#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 问题分析: ...
随机推荐
- 【转】java byte转long、double、float、int、short,或者long、double、float、int、short转byte
原文网址:http://www.xuebuyuan.com/988752.html java byte与其他数据类型的转换主要用于二进制数据的编码和解码,主要用于网络传输,读写二进制文件,java和c ...
- 【转】android使用File Explorer无法访问系统内部文件--不错
原文网址:http://blog.csdn.net/yangqicong11/article/details/8747042 设备:Samsung GT-P3110 系统:Android 4.1.1 ...
- C++ Primer笔记(一):字符串、向量和数组
3.1 命名空间 using namespace::name; using namespace::std using std::cin -- 头文件不应该包含using 3.2 类型string ge ...
- 【android】adb连接几个常见问题(遇到再新增)
不知道为什么,每次连接手机,都提示 adb server is out of date,偶尔也会提示not found 每次去百度,都好多方法---终于有一种方法非常靠谱,遂,记录之--- 问题一:o ...
- HDU_1016——素环问题DFS
Problem Description A ring is compose of n circles as shown in diagram. Put natural number 1, 2, ... ...
- FZU2179/Codeforces 55D beautiful number 数位DP
题目大意: 求 1(m)到n直接有多少个数字x满足 x可以整出这个数字的每一位上的数字 思路: 整除每一位.只需要整除每一位的lcm即可 但是数字太大,dp状态怎么表示呢 发现 1~9的LCM 是2 ...
- Java框架学习之Hibernate入门
Hibernate是一个开放源代码的对象关系映射框架,它对JDBC进行了非常轻量级的对象封装,使得Java程序员可以随心所欲的使用对象编程思维来操纵数据库. Hibernate可以应用在任何使用JDB ...
- Java IntelliJ IDEA 不能显示项目里的文件结构解决办法
按下列步骤操作: 1. 关闭IDEA, 2.然后删除项目文件夹下的.idea文件夹 3.重新用IDEA工具打开项目
- Intent 意图 结构 简介
Intent简介 官方解释: An intent is an abstract description of an operation操作 to be performed展示.表演. It can b ...
- SearchBox( 搜索框) 组件
一. 加载方式//class 加载方式<input id="ss" class="easyui-searchbox" style="width: ...