Skip to content

Commit

Permalink
Define _HAS_EXCEPTIONS=0 when exceptionhandling is "off". (#674)
Browse files Browse the repository at this point in the history
* Define _HAS_EXCEPTIONS=0 when exceptionhandling is "off".

* Fix unit-test.

* It should be for VS2013 and later only.

* update & add unit-test.
  • Loading branch information
tvandijck authored Feb 3, 2017
1 parent 0a7b45c commit 5a4ad51
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/actions/vstudio/vs2010_vcxproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,11 @@


function m.clCompilePreprocessorDefinitions(cfg, condition)
m.preprocessorDefinitions(cfg, cfg.defines, false, condition)
local defines = cfg.defines
if cfg.exceptionhandling == p.OFF and _ACTION >= "vs2013" then
defines = table.join(defines, "_HAS_EXCEPTIONS=0")
end
m.preprocessorDefinitions(cfg, defines, false, condition)
end


Expand Down Expand Up @@ -1965,7 +1969,11 @@


function m.resourcePreprocessorDefinitions(cfg)
m.preprocessorDefinitions(cfg, table.join(cfg.defines, cfg.resdefines), true)
local defines = table.join(cfg.defines, cfg.resdefines)
if cfg.exceptionhandling == p.OFF and _ACTION >= "vs2013" then
table.insert(defines, "_HAS_EXCEPTIONS=0")
end
m.preprocessorDefinitions(cfg, defines, true)
end


Expand Down
5 changes: 5 additions & 0 deletions src/tools/msc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,11 @@
for _, define in ipairs(defines) do
table.insert(result, '/D"' .. define .. '"')
end

if cfg and cfg.exceptionhandling == p.OFF then
table.insert(result, "/D_HAS_EXCEPTIONS=0")
end

return result
end

Expand Down
16 changes: 16 additions & 0 deletions tests/actions/vstudio/vc2010/test_compile_settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,22 @@
]]
end


function suite.exceptions_onNoExceptionsVS2013()
exceptionhandling "Off"
premake.action.set("vs2013")
prepare()
test.capture [[
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>_HAS_EXCEPTIONS=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Optimization>Disabled</Optimization>
<ExceptionHandling>false</ExceptionHandling>
]]
end


function suite.exceptions_onSEH()
exceptionhandling "SEH"
prepare()
Expand Down

0 comments on commit 5a4ad51

Please sign in to comment.