C++ #define #if #ifndef 宏指令

不会用就直接复制粘贴

#define CURSOR(top,bottom) (((top)<<8)|(bottom))
#define mul(x1,x2) (x1*x2)
#define WIDTH 8
#define LENGTH (WIDTH+10)

/**
 * 
 * check is c++ compiler
 */
#if !defined(__cplusplus)
    #error c++ compiler requires
#endif

#if defined(CLANG)//if defined CLANG use below code
   void compiler()
   {
       std::cout<<"use clang"<<std::endl;
   }
#elif defined(GUNC)
    void compiler()
    {
        std::cout<<"use gunc++"<<std::endl;
    }
#else
    void compiler()
    {
        std::cout<<"unknown compiler"<<std::endl;
    }
#endif

#define DLEVEL 5

#if DLEVEL > 5
    #define SIGNAL 1
    #if STACKUSE == 1
        #define STACK 200
    #else 
        #define STACK 100
    #endif
#else
    #define SIGNAL 0
    #if STACKUSE == 1
        #define LEVEL 1
        #define STACK 100
    #else
        #define STACK 50
    #endif
#endif
#if LEVEL == 0
    #define STACK 0
#elif DELEVEL == 1
    #define STACK 100
#elif DLEVEL > 5
    display(debugptr);
#else 
    #define STACK 200
#endif

/* EXAMPLE.H - Example header file*/
#if !defined(EXAMPLE_H)
    #define EXAMPLE_H
class Example
{


};
#endif

/**
 * 
 *Visual Studio 2017 version 15.3 and later,检查库头文件是否包含 
 */
#
#ifdef _has_include
# if _has_include(<filesystem>)
#   inculde <filesystem>
#   define have_filesystem 1
# elif _has_include(<experimental/filesystem>)
#   include <experimental/filesystem>
#   define have_filesystem 1
#   define experimental_filesystem
# else
#   define have_filesystem 0
# endif
#endif

#ifndef test
#define final
#endif

//has no effect
#

//stringizing 操作符转换宏指令参数成字符串字面量.
//比如下面这句 "This: "  prints an escaped double quote"
#define stringer(x) printf(#x "
")


#define F int
#define B def
#define FB(arg) #arg
#define FB1(arg) FB(arg)
原文地址:https://www.cnblogs.com/shuiyonglewodezzzzz/p/10268621.html