diff options
| author | 0xb1aded <[email protected]> | 2026-07-29 18:09:27 +0800 |
|---|---|---|
| committer | 0xb1aded <[email protected]> | 2026-07-30 10:07:21 +0800 |
| commit | 1c520959e8530c8c4bd5148589db385cb324c08f (patch) | |
| tree | b1854ff61a8e717b111e03c1ae2aa17962868771 | |
| parent | a928217681c4c5dc60b80a230182e5254bc30c8d (diff) | |
fix set_pcheader for msvc in c mode
| -rw-r--r-- | xmake/modules/private/action/build/pcheader.lua | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/xmake/modules/private/action/build/pcheader.lua b/xmake/modules/private/action/build/pcheader.lua index 4e984f62b..1682ead8c 100644 --- a/xmake/modules/private/action/build/pcheader.lua +++ b/xmake/modules/private/action/build/pcheader.lua @@ -38,12 +38,24 @@ function config(target, langkind, opt) -- https://github.com/xmake-io/xmake/issues/2667 -- https://github.com/xmake-io/xmake/issues/5858 if not os.isfile(headerfile) then - io.writefile(headerfile, ([[ + local langcxx = (langkind == "cxx" or langkind == "mxx") + local content + if langcxx then + content = [[ #pragma system_header #ifdef __cplusplus #include "%s" #endif // __cplusplus - ]]):format(path.absolute(pcheaderfile):gsub("\\", "/"))) + ]] + else + content = [[ +#pragma system_header +#ifndef __cplusplus +#include "%s" +#endif + ]] + end + io.writefile(headerfile, content:format(path.absolute(pcheaderfile):gsub("\\", "/"))) end -- we need only to add a header wrapper in .gch directory -- @see https://github.com/xmake-io/xmake/issues/5858#issuecomment-2506918167 |
