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

  • 相关阅读:
    2020年秋招三星面试题
    物联网金融和互联网金融的区别与联系
    数据库事务的4种隔离级别
    Access-cookie之sqlmap注入
    SDL-软件安全开发周期流程
    图片马的制作
    ssrf内网端口爆破扫描
    逻辑漏洞_验证码绕过_密码找回漏洞
    平行越权与垂直越权
    xff注入
  • 原文地址:https://www.cnblogs.com/martini/p/2328590.html
Copyright © 2011-2022 走看看