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 基础笔记整理1
    学习开源中国客户端
    IOS项目中的细节处理,如更改状态栏等等
    网络编程
    当FileWriter没有flush的时候,不写入文件
    批量移动文件
    批量重命名文件
    替换一个文件内的某个字符
    遍历map和删除map中的一个entry
    ArrayList的遍历-转载
  • 原文地址:https://www.cnblogs.com/martini/p/2328590.html
Copyright © 2011-2022 走看看