【发布时间】:2015-09-08 23:34:56
【问题描述】:
在 MSVC 和 C# 中,#pragma region 可用于标记代码段。
同样,在 GCC/Clang 中,#pragma mark 可以完成同样的事情。
是否可以定义一个宏,例如CODELABEL(label),它适用于两个编译器?
基本上,我希望避免执行以下操作:
#ifdef _WIN32
#pragma region Variables
#else
#pragma mark Variables
#endif
bool MyBool;
int MyInt;
#ifdef _WIN32
#pragma region Methods
#else
#pragma mark Methods
#endif
void MyMethod();
void AnotherMethod();
...相反,请执行以下操作:
CODELABEL( Variables )
bool MyBool;
int MyInt;
CODELABEL( Functions )
void MyMethod();
void AnotherMethod();
这样的事情可能吗?
【问题讨论】:
标签: c++ region pragma preprocessor-directive