[英]C++ Preprocessor directives as a function parameter
I started learning C++ using a ebook and got interupted by a few lines, which I think are a bit outdated.我开始使用电子书学习 C++ 并被几行打断,我认为这有点过时了。 Anyway, what I am trying to do is using a preprocessor directive as a function parameter which isnt working:
无论如何,我想要做的是使用预处理器指令作为不起作用的函数参数:
#define TitleLabelId 1000;
//....
hTitleText = CreateWindow(L"STATIC",
L"Test Text",
WS_VISIBLE | WS_CHILD,
0, 0,
300, 20,
hWnd,
(HMENU)TitleLabelId,
hInst,
NULL);
This gives me an compile error, while this will give me a correct result:这给了我一个编译错误,而这会给我一个正确的结果:
HMENU hm = (HMENU)TitleLabelId;
hTitleText = CreateWindow(L"STATIC",
L"Test Text",
WS_VISIBLE | WS_CHILD,
0, 0,
300, 20,
hWnd,
(HMENU)TitleLabelId,
hInst,
NULL);
I tried to outsource the Label Text aswell but unfortunateley it didnt work either using the following directive:我也尝试将标签文本外包,但不幸的是它没有使用以下指令工作:
#define TitleText L"Blob Color War";
Is it anything with the syntax I have overseen?这与我监督的语法有什么关系吗? Thanks in advance!
提前致谢!
Use the #define
without the semicolon afterwards:之后使用不带分号的
#define
:
#define TitleLabelId 1000;
// ^
#define TitleLabelId 1000
Otherwise it will be expanded during prprocessing, but is wrong inside the parameter list.否则它会在 prprocessing 期间被扩展,但在参数列表中是错误的。
#define TitleText L"Blob Color War";
I think the ;
我认为
;
is creating some issues.正在制造一些问题。 Removing that would fix it.
删除它会解决它。
#define TitleText L"Blob Color War"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.