对于静态MFC库,我如何检测是否设置了任何"Use Win32“选项?
即
#ifdef ---BuildingForMFC---
....
#else
...
#endif发布于 2009-07-28 21:38:09
我总是检查正在定义的符号_MFC_VER。
这是正在使用的MFC的版本号0x0700 = 7.0
它在MSDN中的“预定义宏”中
发布于 2015-04-28 02:44:43
我已经检查了Visual Studio2013,在一个只针对Win32控制台的原始项目中,所以我必须在第二次添加MFC支持(不使用项目向导)。以下是我的发现:
- A) select "Use MFC in a Shared DLL" option. This actually update the command line parameters adding the definition of \_AFXDLL to the preprocessor macro list.
- B) select "Use MFC in a Static Library" options. This actually remove the \_AFXDLL macro defined, but no macro definition is added, so nothing can told you if MFC is actually used.
因此,在我的测试活动中,只有模式A才能有效地了解MFC库是否包含在正在构建的项目中。
我维护了一个C++跨平台库,它支持许多平台(Mac OSx、MFC控制台、MFC MFC、iOS、Unix、Android),使用动态DLL启用MFC是透明检测WinX存在的唯一方法。举个例子:
#if defined(_AFXDLL)
# include <afx.h>
#endif显然,您可以在项目预处理器列表中手动添加宏定义(_AFX)。
发布于 2009-07-28 21:30:10
符号_AFX通常是为MFC项目定义的。
https://stackoverflow.com/questions/1196808
复制相似问题