diff options
| author | ruki <[email protected]> | 2020-01-23 22:49:14 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-01-23 10:55:24 +0800 |
| commit | d989ec1a9903dde07d08bf58386a45dd53651f6c (patch) | |
| tree | 25dc68e9e4641a53c812d7858a0141f5646cb160 /xmake/modules/core | |
| parent | 17d5e2d5fd3f1d10c0598068cfd58412f848243e (diff) | |
support to compile *.c as c++
Diffstat (limited to 'xmake/modules/core')
| -rw-r--r-- | xmake/modules/core/tools/cl.lua | 9 | ||||
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 9 |
2 files changed, 18 insertions, 0 deletions
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua index 899258e38..5ce63f6c7 100644 --- a/xmake/modules/core/tools/cl.lua +++ b/xmake/modules/core/tools/cl.lua @@ -30,6 +30,15 @@ function init(self) -- init cxflags self:set("cxflags", "-nologo") + -- set language type explicitly + -- + -- because compiler maybe compile `.c` as c++. + -- e.g. + -- add_files("*.c", {sourcekind = "cxx"}) + -- + self:add("cflags", "-TC") + self:add("cxxflags", "-TP") + -- init flags map self:set("mapflags", { diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 8fb5a4d81..6daeb2fd6 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -46,6 +46,15 @@ function init(self) self:add("shared.cxflags", "-fPIC") end + -- set language type explicitly + -- + -- because compiler maybe compile `.c` as c++. + -- e.g. + -- add_files("*.c", {sourcekind = "cxx"}) + -- + self:add("cflags", "-x c") + self:add("cxxflags", "-x c++") + -- init flags map self:set("mapflags", { |
