相关疑难解决方法(0)

在预处理程序指令中使用变量

哪个全局变量可以在预处理程序指令file.cpp中使用

int variable = 1;
#if variable >= 1
    int a = 0;
#else 
    int a = 1;
#endif
Run Code Online (Sandbox Code Playgroud)

要么

file.cpp

const int variable = 1;
#if variable >= 1
    int a = 0;
#else 
    int a = 1;
#endif
Run Code Online (Sandbox Code Playgroud)

或file.cpp

#include "header.h"
// extern in variable; in the header.h
#if variable >= 1
    int a = 0;
#else 
    int a = 1;
#endif
Run Code Online (Sandbox Code Playgroud)

使用proprocessor指令中的变量的规则是什么?如果一个可以折叠的变量,它可以用在#if /#elif#else指令中吗?

c c++ preprocessor-directive

0
推荐指数
1
解决办法
2044
查看次数

标签 统计

c ×1

c++ ×1

preprocessor-directive ×1