blob: 22ee1bdcfc09fb59b748940f9e1c23cfbed8786e [file] [log] [blame]
Patrick Williamsb48b7b42016-08-17 15:04:38 -05001From 99444b3d2c4a4f7fd7128e60461005780d0c5c83 Mon Sep 17 00:00:00 2001
2From: "Gary E. Miller" <gem@rellim.com>
3Date: Sun, 15 Mar 2015 12:05:15 -0700
4Subject: [PATCH 2/3] Add a test for C11 and check we have C11 before using
5 stdatomic.h
6
7---
8 SConstruct | 19 ++++++++++++++++++-
9 1 file changed, 18 insertions(+), 1 deletion(-)
10
11diff --git a/SConstruct b/SConstruct
12index 566c14a..faa8651 100644
13--- a/SConstruct
14+++ b/SConstruct
15@@ -473,6 +473,20 @@ def CheckCompilerDefines(context, define):
16 context.Result(ret)
17 return ret
18
19+# Check if this compiler is C11 or better
20+def CheckC11(context):
21+ context.Message( 'Checking if compiler is C11 ...' )
22+ ret = context.TryLink("""
23+ #if (__STDC_VERSION__ < 201112L)
24+ #error Not C11
25+ #endif
26+ int main(int argc, char **argv) {
27+ return 0;
28+ }
29+ """,'.c')
30+ context.Result(ret)
31+ return ret
32+
33 def GetLoadPath(context):
34 context.Message("Getting system load path ...")
35
36@@ -491,6 +505,7 @@ else:
37 'CheckXsltproc' : CheckXsltproc,
38 'CheckCompilerOption' : CheckCompilerOption,
39 'CheckCompilerDefines' : CheckCompilerDefines,
40+ 'CheckC11' : CheckC11,
41 'CheckHeaderDefines' : CheckHeaderDefines})
42
43
44@@ -633,7 +648,9 @@ else:
45 announce("You do not have kernel CANbus available.")
46 env["nmea2000"] = False
47
48- if not config.CheckCompilerDefines("__STDC_NO_ATOMICS__") and config.CheckHeader("stdatomic.h"):
49+ # check for C11 or better, and __STDC__NO_ATOMICS__ is no defined
50+ # before looking for stdatomic.h
51+ if not config.CheckC11() and not config.CheckCompilerDefines("__STDC_NO_ATOMICS__") and config.CheckHeader("stdatomic.h"):
52 confdefs.append("#define HAVE_STDATOMIC_H 1\n")
53 else:
54 confdefs.append("/* #undef HAVE_STDATOMIC_H */\n")
55--
562.1.0
57