在读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 的意思?的更多相关文章

  1. 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 ...

  2. 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 ...

  3. _WIN32_WINNT not defined. Defaulting to _WIN32_WINNT_MAXVER (see WinSDKVer.h)

    原文地址::http://blog.csdn.net/xiaolongwang2010/article/details/7550505 相关网帖 1.错误找不到WinsdkVer.h----http: ...

  4. VC++ : error LNK2005: ... already defined in *.obj

    今天写代码遇到了这么一个链接错误:"已经在*.obj中定义". error LNK2005: "void __cdecl ReplaceWstringVar(class ...

  5. Target runtime com.genuitec.runtime.generic.jee60 is not defined

    转载自:http://jingyan.baidu.com/article/d7130635338e3f13fdf47518.html 用eclipse加载别人的工程,报错Target runtime ...

  6. TOMCAT-报错The BASEDIR environment variable is not defined correctly

    <span style="font-size:18px;">The BASEDIR environment variable is not defined correc ...

  7. MySql.Data.MySqlClient.MySqlException: Parameter ‘@maxid’ must be defined

    本文涉及到的mysql知识点: mysql中的if条件语句用法: IF(expr1,expr2,expr3) mysql使用变量(mysql中变量不用事前申明) mysql事务 testcase 为了 ...

  8. SQL SERVER中用户定义标量函数(scalar user defined function)的性能问题

    用户定义函数(UDF)分类  SQL SERVER中的用户定义函数(User Defined Functions 简称UDF)分为标量函数(Scalar-Valued Function)和表值函数(T ...

  9. no result defined for action

    1.no result defined for action .......and result input    或者 no result defined for action .......and ...

  10. 解决:Error: JAVA_HOME is not defined correctly

    问题重现: Error: JAVA_HOME is not defined correctly. We cannot execute :/usr/lib/jvm/java-7-oracle 问题分析: ...

随机推荐

  1. MD中bitmap源代码分析--入题概述

    在MD模块中,各级raid都使用的一份bitmap的源码,也就是说共用一种bitmap的流程,下面以raid1的使用为例来分析bitmap的工作原理. 在使用raid1磁盘阵列的时候,对于数据的可靠性 ...

  2. Create a simple REST web service with Python--转载

    今日尝试用python建立一个restful服务. 原文地址:http://www.dreamsyssoft.com/python-scripting-tutorial/create-simple-r ...

  3. s16_day01

    一.基础 1.编码 ascii-->GB2312-->GB18030-->GBK-->unicode-->UTF8可变长 2.数据类型 int,long,float,co ...

  4. Odoo “坑” 系列之 XML中的布尔类型

    在Odoo中试图通过XML方式更新某条Record的值,却意外发现根本不能更新,经查,对于XML中Boolean类型的字段,更新的方式应该采用eval的方式.

  5. final(最终、修饰符)

    /* final(最终.修饰符) final关键字的用法: 1. final关键字修饰一个基本类型的变量时,该变量不能重新赋值,第一次的值为最终的. 2. fianl关键字修饰一个引用类型变量时,该变 ...

  6. Objective-C基础学习笔记——对象初始化

    obj中创建新对象有两种方式:[classname new]和[[classname alloc] init].两种方法等价,Cocoa惯例是使用alloc和init. 1.分配对象: allocat ...

  7. fstab的格式

    # /etc/fstab/dev/hda8 swap swap defaults 0 0/dev/hda9 / ext2 defaults 1 1/dev/hda6 /wine vfat defaul ...

  8. 一步步启动linux

    可以一步一步启动linux. 在Ubantu刚一启动时,按c健即进入Grub>提示符状态,在此状态下输入(我用的是Ubuntu 13) grub>linux /vmlinuz grub&g ...

  9. java中的变量

    变量就是命名的内存空间 1.声明和赋值方式:数据类型   变量名 = 值: 数据类型即划分的内存空间,变量名即划分出的内存空间的名 2.变量必须先声明才能使用,不能使用一个没有经过预先声明的变量:没有 ...

  10. html拼接数据的时候一定要注意null值的问题

    后台会返回null文本  如果直接拼接 不仅仅格式问题 前台会显示null   如果是图片  用fiddle抓取 还会发现你请求了一个带域名/null的接口     所以要把null格式化为空文本