From 8f80d4f01d31bf3a873e7b5797d3ed97c569f23e Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 19 Mar 2023 23:44:35 +0800 Subject: improve to check main --- tests/apis/check_xxx/xmake.lua | 3 ++- xmake/modules/lib/detect/check_cxsnippets.lua | 2 +- 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 -- cgit v1.3.1