I checked Visual Studio 2013 in the original project focused only on the Win32 console, so I have to add MFC support (without using the Project Wizard) a second time. Below are my findings:
The _MFC_VER macro is defined in afxver_.h included by afx.h. So, if you do not include afx.h directly / indirectly in your .cpp file, you do not have the _MFC_VER macro. For example, by including a .cpp source in the project that does not include afx.h, the file will be compiled WITHOUT the _MFC_VER macro definition. Therefore, it is useless to adapt C ++ code (for example, an external library) to detect the use of the MFC library and, if necessary, support for the MFC library.
If you manually enable the use of MFC (select the project in the solution explorer than right-click Configuration Properties → General → Use MFC), you have two options:
- A) select "Use MFC in the shared DLL". This actually updates the command line options by adding the _AFXDLL definition to the list of preprocessor macros.
- B) select the option "Use MFC in the static library". This actually removes the _AFXDLL macro, but no macro definition is added, so nothing can tell you if MFC is actually used.
Thus, during my test activity, only mode A can be effectively used to understand whether the MFC library is included or not in the project under the building.
I support the cross-platform C ++ library that supports many platforms (Mac OSx, WinX console, WinX MFC, iOS, Unix, Android) and allows MFC with a dynamic DLL - the only way to transparently detect the presence of MFC. For example:
#if defined(_AFXDLL) # include <afx.h> #endif
Obviusly, you can manually add a macro definition (_AFX) to the project preprocessor list.
Mouze
source share