diff --git a/lib/cppcheck.cpp b/lib/cppcheck.cpp index b20d97228..f8427ae02 100644 --- a/lib/cppcheck.cpp +++ b/lib/cppcheck.cpp @@ -334,6 +334,12 @@ unsigned int CppCheck::check(const std::string &path) #endif std::string flags(lang + " "); + if (mSettings.standards.cpp == Standards::CPP14) + flags += "-std=c++14 "; + else if (mSettings.standards.cpp == Standards::CPP17) + flags += "-std=c++17 "; + else if (mSettings.standards.cpp == Standards::CPP20) + flags += "-std=c++20 "; for (const std::string &i: mSettings.includePaths) flags += "-I" + i + " "; @@ -401,6 +407,12 @@ unsigned int CppCheck::check(const ImportProject::FileSettings &fs) temp.mSettings.userDefines += fs.cppcheckDefines(); temp.mSettings.includePaths = fs.includePaths; temp.mSettings.userUndefs = fs.undefs; + if (fs.standard == "c++14") + temp.mSettings.standards.cpp = Standards::CPP14; + else if (fs.standard == "c++17") + temp.mSettings.standards.cpp = Standards::CPP17; + else if (fs.standard == "c++20") + temp.mSettings.standards.cpp = Standards::CPP20; if (fs.platformType != Settings::Unspecified) temp.mSettings.platform(fs.platformType); if (mSettings.clang) { diff --git a/lib/importproject.cpp b/lib/importproject.cpp index 9c073be41..0f27e6532 100644 --- a/lib/importproject.cpp +++ b/lib/importproject.cpp @@ -469,6 +469,11 @@ namespace { if (!additionalIncludePaths.empty()) additionalIncludePaths += ';'; additionalIncludePaths += e->GetText(); + } else if (std::strcmp(e->Name(), "LanguageStandard") == 0) { + if (std::strcmp(e->GetText(), "stdcpp14") == 0) + cppstd = Standards::CPP14; + else if (std::strcmp(e->GetText(), "stdcpp17") == 0) + cppstd = Standards::CPP17; } } } @@ -508,6 +513,7 @@ namespace { std::string condition; std::string preprocessorDefinitions; std::string additionalIncludePaths; + Standards::cppstd_t cppstd = Standards::CPPLatest; }; } @@ -696,6 +702,14 @@ void ImportProject::importVcxproj(const std::string &filename, std::map