summaryrefslogtreecommitdiff
path: root/xmake/modules/detect
diff options
context:
space:
mode:
authorruki <[email protected]>2021-09-29 23:37:41 +0800
committerruki <[email protected]>2021-09-29 23:37:41 +0800
commit2c906bc87c0140c20509ee2063b64188375225f2 (patch)
tree4c47ac0d606ce270ba93c7305cd2354009ba8876 /xmake/modules/detect
parentdb6fe6c5fafdac2e719fcfbfc9dbe305ed4cf606 (diff)
improve detect c17
Diffstat (limited to 'xmake/modules/detect')
-rw-r--r--xmake/modules/detect/tools/clang/cfeatures.lua3
-rw-r--r--xmake/modules/detect/tools/gcc/cfeatures.lua2
2 files changed, 5 insertions, 0 deletions
diff --git a/xmake/modules/detect/tools/clang/cfeatures.lua b/xmake/modules/detect/tools/clang/cfeatures.lua
index 8c462a16f..e9a1687a6 100644
--- a/xmake/modules/detect/tools/clang/cfeatures.lua
+++ b/xmake/modules/detect/tools/clang/cfeatures.lua
@@ -33,7 +33,9 @@ function main()
_g.features = cfeatures()
-- init conditions
+ -- clang -std=c11 -dM -E - < /dev/null | grep __STDC_VERSION__
local clang_minver = "((__clang_major__ * 100) + __clang_minor__) >= 304"
+ local c17 = clang_minver .. " && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201710L"
local c11 = clang_minver .. " && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L"
local c99 = clang_minver .. " && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L"
local c90 = clang_minver
@@ -42,6 +44,7 @@ function main()
_set("c_std_89", c90)
_set("c_std_99", c99)
_set("c_std_11", c11)
+ _set("c_std_17", c17)
-- set features
_set("c_static_assert", c11)
diff --git a/xmake/modules/detect/tools/gcc/cfeatures.lua b/xmake/modules/detect/tools/gcc/cfeatures.lua
index 9f4ee275b..b9ebaa036 100644
--- a/xmake/modules/detect/tools/gcc/cfeatures.lua
+++ b/xmake/modules/detect/tools/gcc/cfeatures.lua
@@ -29,6 +29,7 @@ function main()
-- init conditions
local gcc_minver = "(__GNUC__ * 100 + __GNUC_MINOR__) >= 304"
+ local gcc10_c17 = "(__GNUC__ * 100 + __GNUC_MINOR__) >= 1000 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201710L"
local gcc46_c11 = "(__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201000L"
local gcc34_c99 = "(__GNUC__ * 100 + __GNUC_MINOR__) >= 304 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L"
local gcc_c90 = gcc_minver
@@ -37,6 +38,7 @@ function main()
_set("c_std_89", gcc46_c90)
_set("c_std_99", gcc34_c99)
_set("c_std_11", gcc46_c11)
+ _set("c_std_17", gcc46_c17)
-- set features
_set("c_static_assert", gcc46_c11) -- GNU 4.7 correctly sets __STDC_VERSION__ to 201112L, but GNU 4.6 sets it to 201000L