在编译时要不要删除?
#include <iostream>
#include <stdio.h>
//#include <string.h>
//using namespace std;
#define N 0
// 检测宏定义是否存在
#define py
int main()
{
// 预处理 分支 会根据条件在编译时进行选择性的删除
// 里面必须使用常量
#if N == 1
std::cout << "N=1" << std::endl;
#elif N == 2
std::cout << "N=2" << std::endl;
#else
std::cout << "N=3" << std::endl;
#endif
// 检测宏定义是否存在, 存在则保留 不存在则删除该部分代码
#ifdef py
std::cout << "py -- > True yes" << std::endl;
#endif
// 检测宏定义是否 不存在, 与上面相反
#ifndef py1
std::cout << "py1 -- > True No" << std::endl;
#endif
return 0;
}