diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index dd0604794..6cb711fa9 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -93,7 +93,7 @@ unsigned int CppCheck::check(const ImportProject::FileSettings &fs) { CppCheck temp(_errorLogger, _useGlobalSuppressions); temp._settings = _settings; - temp._settings.userDefines = fs.defines; + temp._settings.userDefines = fs.cppcheckDefines(); temp._settings.includePaths = fs.includePaths; // TODO: temp._settings.userUndefs = fs.undefs; if (fs.platformType != Settings::Unspecified) { diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 9e784e19f..3f9d157f2 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -495,15 +495,14 @@ void ImportProject::importVcxproj(const std::string &filename, std::mapname; - fs.defines = "_MSC_VER=1900;_WIN32=1"; + fs.defines = "_WIN32=1"; if (p->platform == ProjectConfiguration::Win32) fs.platformType = cppcheck::Platform::Win32W; else if (p->platform == ProjectConfiguration::x64) { fs.platformType = cppcheck::Platform::Win64; fs.defines += ";_WIN64=1"; } - if (useOfMfc) - fs.defines += ";__AFXWIN_H__"; + fs.useMfc = useOfMfc; std::string additionalIncludePaths; for (std::list::const_iterator i = itemDefinitionGroupList.begin(); i != itemDefinitionGroupList.end(); ++i) { if (!i->conditionIsTrue(*p)) diff --git a/lib/importproject.h b/lib/importproject.h index 870630180..456e8d812 100644 --- a/lib/importproject.h +++ b/lib/importproject.h @@ -40,15 +40,19 @@ class CPPCHECKLIB ImportProject { public: /** File settings. Multiple configurations for a file is allowed. */ struct FileSettings { - FileSettings() : platformType(cppcheck::Platform::Unspecified) {} + FileSettings() : platformType(cppcheck::Platform::Unspecified), useMfc(false) {} std::string cfg; std::string filename; std::string defines; + std::string cppcheckDefines() const { + return useMfc ? (defines + ";_MSC_VER=1900;__AFXWIN_H__=1") : defines; + } std::set undefs; std::list includePaths; std::list systemIncludePaths; std::string standard; cppcheck::Platform::PlatformType platformType; + bool useMfc; void setDefines(std::string defs); void setIncludePaths(const std::string &basepath, const std::list &in, std::map &variables);