Is there a macro I can use for checking the current configuration type in visual studio? Depending on the current setting I'd like to either include a main or dllmain function:
#IFDEF CONFIGURATION_TYPE_EXE
int main(int argc, char **argv)
{
...
}
#ELSEIF CONFIGURATION_TYPE_DLL
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
return TRUE;
}
#ENDIF
If it's dll then _WINDLL will be defined as inherited value. You can find it here: Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions.
#ifdef _WINDLL
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{ ... }
#else
int main(int argc, char** argv)
{ ... }
#endif
If it's a DLL project, the _USRDLL
will be defined. (see Configuration Properties\Preprocessor\Preprocessor definitions).
Be careful though, because the list is filled by wizard and will not update automatically if the project was created as something else and then configured as DLL. Also, you have to be careful if you are building a lib to be linked with a DLL.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With