Use the #define
without the semicolon afterwards:
#define TitleLabelId 1000;
// ^
#define TitleLabelId 1000
Otherwise it will be expanded during prprocessing, but is wrong inside the parameter list.
Вопрос
I started learning C++ using a ebook and got interupted by a few lines, which I think are a bit outdated. 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 TitleLabelId 1000;
// ^
#define TitleLabelId 1000
Otherwise it will be expanded during prprocessing, but is wrong inside the parameter list.
Другие советы
#define TitleText L"Blob Color War";
I think the ;
is creating some issues. Removing that would fix it.
#define TitleText L"Blob Color War"