Visual Studio:用于检查配置类型的宏(exe/dll)
我可以使用宏来检查 Visual Studio 中的当前配置类型吗? 根据当前设置,我想包含 main 或 dllmain 函数:
#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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果它是dll,那么_WINDLL将被定义为继承值。您可以在这里找到它:配置属性-> C/C++->预处理器->预处理器定义。
If it's dll then _WINDLL will be defined as inherited value. You can find it here: Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions.
如果是 DLL 项目,则将定义
_USRDLL
。 (请参阅配置属性\预处理器\预处理器定义)。但要小心,因为该列表是由向导填充的,如果该项目是作为其他内容创建的,然后配置为 DLL,则该列表不会自动更新。另外,如果您正在构建要与 DLL 链接的库,则必须小心。
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.