所以这是我的代码:
// Defines a tuple
#define __WINDOW__RESOLUTION__ 500, 200
// Seperate the tuple
#define __WINDOW__X__1(Width, Height) (Width)
#define __WINDOW__Y__1(Width, Height) (Height)
// Add another sort of indirection because my tuple is a macro
#define __WINDOW__X__(Macro) __WINDOW__X__1(Macro)
#define __WINDOW__Y__(Macro) __WINDOW__Y__1(Macro)
// These should be the final values 500 and 200
#define __WINDOW__RESOLUTION__X__ (__WINDOW__X__(__WINDOW__RESOLUTION__))
#define __WINDOW__RESOLUTION__Y__ (__WINDOW__Y__(__WINDOW__RESOLUTION__))
当我使用最终数字应该是的第一个宏时,似乎出了点问题:
std::cout << __WINDOW__RESOLUTION__X__ << std::endl; // Outputs 200 instead of 500
上面的行输出数字 200,所以 Y 值而不是 X 值
std::cout << __WINDOW__RESOLUTION__Y__ << std::endl; // ERR with macro underlined
这一行甚至无法编译 [C2059,语法错误:“)”]
谢谢你帮助我亚历克斯