zoukankan      html  css  js  c++  java
  • #if defined 和#ifdef的区别

    基本上一样,不过后者的应用范围更大,可以支持多个预编译变量的检查:

    #if (!defined(_DEBUG) && defined(USE_MYLIB))

      ..........

    #endif

    这种情况用前一种方式就只能写一个嵌套的条件判断:

    #ifndef _DEBUG

      #ifdef USE_MYLIB

        ................

      #endif

    #endif

    ------------------------------------------------------------------

    -------------------这是在vc6.0中自动生成的一个-------------------

    #if !defined(AFX_AB_H__180F7416_66D6_44B0_A73C_5FB1E376CD48__INCLUDED_)

    #define AFX_AB_H__180F7416_66D6_44B0_A73C_5FB1E376CD48__INCLUDED_

    #if _MSC_VER > 1000

    #pragma once

    #endif       // _MSC_VER > 1000

    #include "string"

    class AB 

    {

    public:

     std::string s;

     AB(const std::string _s);

     virtual ~AB();

    };

    #endif      // !defined(AFX_AB_H__180F7416_66D6_44B0_A73C_5FB1E376CD48__INCLUDED_)

     

    ------------------------------------------------------------

    #ifdef   #ifndef  #define  #if !defined(...)   #if defined(...)

    #else  ....

    以 #endif 结束

    ------------------------------------------------------------

     

     

    #define 和 #undef

    c/c++宏代码

    #define TEST_A 1                      // 定义宏 TEST_A  为 1

    #define TEST_CLASS_A clase T1       // 定义宏TEST_CLASS_A 为 clase T1        

    #include " TEST.h "

    #undef   TEST_A                     // 取消宏 TEST_A,为了后面重新定义宏TEST_A  为 2

    #undef   TEST_CLASS_A         // 取消宏 TEST_CLASS_A 为了后面重新定义宏 TEST_CLASS_A 为 clase T1 clase T2

        

    #define TEST_A 2                      // 重新定义宏 TEST_A  为 2,

    #define TEST_CLASS_A clase T1 clase T2

    #include " TEST.h "

    #undef   TEST_A

    #undef   TEST_CLASS_A

  • 相关阅读:
    git操作
    计算天数
    web小结~2019.3.24
    数据统计值的计算+PYTHON
    python~序列类型及操作
    一个日期加上若干天后是什么日期
    完数与盈数
    分段函数
    求最大最小
    D进制的A+B
  • 原文地址:https://www.cnblogs.com/martini/p/2328590.html
Copyright © 2011-2022 走看看