summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-09-05 19:42:51 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-09-05 19:42:51 +0200
commita8e3feb7885d5f15efd8207ecf181df3da39022b (patch)
tree9fe0af22eb49a46a06e6f8ac95fa1b7dfee77e5c
parent38447c545e3d86fcaaa4a323e2161d72c5ff5959 (diff)
parent4c84cb6ae8dc241eb3f50dd8899132024592dee2 (diff)
downloadredot-engine-a8e3feb7885d5f15efd8207ecf181df3da39022b.tar.gz
Merge pull request #96244 from Repiteo/scons/msvc-__cplusplus
SCons: Pass `/Zc:__cplusplus` in MSVC builds
-rw-r--r--SConstruct2
-rw-r--r--core/typedefs.h3
2 files changed, 5 insertions, 0 deletions
diff --git a/SConstruct b/SConstruct
index 0297cd6e61..5c1ccd2449 100644
--- a/SConstruct
+++ b/SConstruct
@@ -791,6 +791,8 @@ else:
# Note that this is still not complete conformance, as certain Windows-related headers
# don't compile under complete conformance.
env.Prepend(CCFLAGS=["/permissive-"])
+ # Allow use of `__cplusplus` macro to determine C++ standard universally.
+ env.Prepend(CXXFLAGS=["/Zc:__cplusplus"])
# Disable exception handling. Godot doesn't use exceptions anywhere, and this
# saves around 20% of binary size and very significant build time (GH-80513).
diff --git a/core/typedefs.h b/core/typedefs.h
index 0de803293d..35c4668581 100644
--- a/core/typedefs.h
+++ b/core/typedefs.h
@@ -44,6 +44,9 @@
#include "core/error/error_list.h"
#include <cstdint>
+// Ensure that C++ standard is at least C++17. If on MSVC, also ensures that the `Zc:__cplusplus` flag is present.
+static_assert(__cplusplus >= 201703L);
+
// Turn argument to string constant:
// https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html#Stringizing
#ifndef _STR