(02-18-2022, 06:31 AM)1e9t8m29 Wrote: If _dwmain is declared like this: int _dwmain(a, b) then where is the definition of it? It can't be the int WINAPI WinMain because this very function return _dwmain(argc, argv).
Please give me the preprocessed (by hand) of that snippet, I want to know what you actually wanted to write in plain C code, without macros. Thanks.
Ok the way these type of preprocessor macros work is they replace anything starting with "dwmain(" and ending with ")" ... the a and b will be filled in with whatever is in those positions.
So an entrypoint defintiion like this:
Code:
int dwmain(int argc, char **argv)
{
return 0;
}
would result in the following code being generated:
Code:
int _dwmain(int argc, char **argv);
char ** API _dw_convertargs(int *count, char *start, HINSTANCE hInstance);
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
int argc;
char **argv = _dw_convertargs(&argc, lpCmdLine, hInstance);
return _dwmain(argc, argv); }
int _dwmain(int argc, char **argv)
{
return 0;
}
The _dwmain definition starts with "int" because that was before the "dwmain(" macro.
So this one definition creates 2 functions.... the WinMain() function, which is the actual application entrypoint and a _dwmain() internal function which contains your code.
The WinMain() function does the work of converting the arguments and then calls the internal function containing your code.
Make more sense now?
Brian