zoukankan      html  css  js  c++  java
  • 宏定义中的条件判断

    例子

    常用的

    #ifdef

    #endif

    高阶版

    #if( defined(宏1) || defined(宏2))

    #endif

    集合

    #define            定义一个预处理宏
    #undef            取消宏的定义

    #if                   编译预处理中的条件命令,相当于C语法中的if语句
    #ifdef              判断某个宏是否被定义,若已定义,执行随后的语句
    #ifndef            与#ifdef相反,判断某个宏是否未被定义
    #elif                若#if, #ifdef, #ifndef或前面的#elif条件不满足,则执行#elif之后的语句,相当于C语法中的else-if
    #else              与#if, #ifdef, #ifndef对应, 若这些条件不满足,则执行#else之后的语句,相当于C语法中的else
    #endif             #if, #ifdef, #ifndef这些条件命令的结束标志.
    defined          与#if, #elif配合使用,判断某个宏是否被定义

    关于宏定义的秒用:

    1.头文件包含

    2.版本控制

    3.硬件控制

    4.代码标准化等

  • 相关阅读:
    python函数嵌套的实用技术
    windows10 装linux子系统
    彻底测试全部拷贝list相关操作的区别python
    c语言学习
    Pickling
    Filenames and paths
    Format operator
    Reading and writing
    Persistence
    Automation testing tool comparison
  • 原文地址:https://www.cnblogs.com/ice-arrow/p/13744077.html
Copyright © 2011-2022 走看看