summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-09-20 10:22:54 -0400
committerBen Gamari <ben@smart-cactus.org>2021-10-12 13:56:49 -0400
commitf9fe84abc25c472e3a40acb4f125864d3506e44d (patch)
treef4ecaff9d0d76a5ea5076164a6f30d5847cfd10a
parenta91e2e36822b8537ab0003e336dd1824f32462a5 (diff)
downloadhaskell-f9fe84abc25c472e3a40acb4f125864d3506e44d.tar.gz
rts: Ensure that headers don't refer to undefined __STDC_VERSION__
Previously the C/C++ language version check in STG could throw an undefined macro warning due to __STDC_VERSION__ when compiled with a C++ compiler. Fix this by defining __STDC_VERSION__==0 when compiling with a C++ compiler. Fixes #20394. (cherry picked from commit e78752df0cb5c22826d75751229b017b58f6dcab)
-rw-r--r--includes/Stg.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/includes/Stg.h b/includes/Stg.h
index 46f71c0241..981e72e808 100644
--- a/includes/Stg.h
+++ b/includes/Stg.h
@@ -25,6 +25,12 @@
#pragma once
+// Ensure that we don't get a -Wundef warning for __STDC_VERSION if compiling
+// with a C++ compiler. See #20394.
+#if defined(__cplusplus)
+#define __STDC_VERSION__ 0
+#endif
+
#if !(__STDC_VERSION__ >= 199901L) && !(__cplusplus >= 201103L)
# error __STDC_VERSION__ does not advertise C99, C++11 or later
#endif