I recently found some interesting macro while browsing random sources around the internet:
#define CWA(dll, api) ::api
Someone can explain me what is that macro and what else it needs to make it works ?
Here is example where its used:
CWA(user32, MessageBoxW)(NULL, L"Hello world!", NULL, MB_OK);
I think its used to tell to compiler/linker to use some specific import type for APIs or something….
Thanks in advance.
Preprocessor language is quite easy to read. You have macro:
It is used by code:
So the result of preprocessing is:
Notice that “api” is just second argument of macro, so basically macro has two arguments: first is ignored, second is name of global function (:: is prefix for calling global function, e.g. ::MyGlobalFunc).
First argument “dll” is ignored, so it serves just as comment, in what dll the function is.
Edit: possible reason behind it – somebody wants to clearly document calls to global functions to other DLLs. It nicely reads: “I am calling function MessageBoxW from user32.dll”.