我有以下用例
#define ConstantDouble( T )\
T( Alert, c_alert )
// I want to generate #define macro's dynamically
#define T( x, y ) #define #x y <-- Error
ConstantDouble( T )
#undef T
#define Constant( x ) Constants::x ; <-- x is Alert and I want the prev #define to kick in and convert this to c_alert
// Want to generate members variables directly
class Constants
{
#define T( x, y ) static double y;
ConstantDouble( T )
#undef T
};
这有解决方法吗?
我想以我的名义拥有这样的东西
Constant( "Alert" )
这被转换为Constants::c_alert;