From d6842007a893330b8d447c845b885b40f43c4f61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 25 Apr 2021 21:16:04 +0200 Subject: [PATCH] Preprocessor; Set proper __cplusplus define value --- lib/preprocessor.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/preprocessor.cpp b/lib/preprocessor.cpp index 8f3c04616..0889e2888 100644 --- a/lib/preprocessor.cpp +++ b/lib/preprocessor.cpp @@ -645,8 +645,18 @@ static simplecpp::DUI createDUI(const Settings &mSettings, const std::string &cf dui.defines.push_back(s); } - if (Path::isCPP(filename)) - dui.defines.emplace_back("__cplusplus"); + if (Path::isCPP(filename)) { + if (mSettings.standards.cpp == Standards::CPP11) + dui.defines.emplace_back("__cplusplus=201103L"); + else if (mSettings.standards.cpp == Standards::CPP14) + dui.defines.emplace_back("__cplusplus=201402L"); + else if (mSettings.standards.cpp == Standards::CPP17) + dui.defines.emplace_back("__cplusplus=201703L"); + else if (mSettings.standards.cpp == Standards::CPP20) + dui.defines.emplace_back("__cplusplus=202002L"); + else + dui.defines.emplace_back("__cplusplus"); + } dui.undefined = mSettings.userUndefs; // -U dui.includePaths = mSettings.includePaths; // -I