summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-03-19 23:44:35 +0800
committerruki <[email protected]>2023-03-19 23:44:35 +0800
commit8f80d4f01d31bf3a873e7b5797d3ed97c569f23e (patch)
treebb07538f96a645b0f50dfa0ddbe3f0649463fa0e
parent3bffb973b717facc6fe7c0728a8993ff03ce9c87 (diff)
improve to check main
-rw-r--r--tests/apis/check_xxx/xmake.lua3
-rw-r--r--xmake/modules/lib/detect/check_cxsnippets.lua2
2 files changed, 3 insertions, 2 deletions
diff --git a/tests/apis/check_xxx/xmake.lua b/tests/apis/check_xxx/xmake.lua
index ae13514e5..a5c748414 100644
--- a/tests/apis/check_xxx/xmake.lua
+++ b/tests/apis/check_xxx/xmake.lua
@@ -20,7 +20,8 @@ target("foo")
int test() {
return (sizeof(int) == 4)? 0 : -1;
}
- int main(int argc, char** argv) {
+ int main(int argc, char** argv)
+ {
return test();
}]], {tryrun = true})
check_csnippets("INT_SIZE", 'printf("%d", sizeof(int)); return 0;', {output = true, number = true})
diff --git a/xmake/modules/lib/detect/check_cxsnippets.lua b/xmake/modules/lib/detect/check_cxsnippets.lua
index 922b7eac6..32de0bee4 100644
--- a/xmake/modules/lib/detect/check_cxsnippets.lua
+++ b/xmake/modules/lib/detect/check_cxsnippets.lua
@@ -79,7 +79,7 @@ function _sourcecode(snippets, opt)
local has_main = false
for _, snippet in pairs(snippets) do
-- find int main(int argc, char** argv) {}
- if snippet:find("%s+main%s*%(.-%)") then
+ if snippet:find("int%s+main%s*%(.-%)%s*{") then
has_main = true
break
end