Note about Visual Studio Compiler Flags - Part 1 (5 flags)

/EHs, /EHc, /EHa, /EHsc (Exception type support)

Project Properties->C++->Code Generation->Enable C++ Exception

For

  • /EHs: Program supports C++ Standard Exception
  • /EHsc: Program supports C++ Standard Exception, but compiler assumes extern C function never throw the Exception
  • /EHa: Program supports C++ Standard Exception and Microsoft Asynchronized Exception(from hardware)
  • not set the /ET flag: No any exception supports

Should

Use /EHs, if you follow the C++ standard.
Never use /EHa. Check http://blogs.msdn.com/b/larryosterman/archive/2004/09/10/228068.aspx
Disable /EH, if you wanna speed up your program(if you have the evidence that exception is the bottleneck.) According to More Effective C++ Rule15, program which supports Excpetion is 5%~10% slower.

realted post:

http://msdn.microsoft.com/zh-tw/library/1deeycx5.aspx

/INCREMENTAL (for debug)

Project Properties->Linker->General->Enable Incremental Linking = Yes

For:

compile/link faster

Should:

use in debug, set no in release

related warning messages:

warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification
warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification

related post:

http://stackoverflow.com/questions/3349521/what-is-incremental-linking

/EDITANDCONTINUE (for debug)

Menu->Tools->Options.-> Debugging node->Edit and Continue category

For:

Edit and continue allows you to change code while you are debugging and just keep the program running. It's not supported if the code also has to be optimized.

Should:

you put "Edit and continue" on debug builds.

/SAFESEH, (for release)

Project Properties -> Linker folder -> Command Line-> Additional

For:

/SAFESEH generates stack unwinding info in a table rather than using the stack

Should:

/SAFESEH makes no sense in the debug build. Only use that linker option in the Release build.

/errorreport (ANY)

Project Properties->Linker->Advanced->PromptImmediately (/ERRORREPORT:PROMPT)

For:

Help Microsoft to collect the internal compiler (Clang.exe) problem/crash/issues.

Should:

If you like Microsoft

related post

http://msdn.microsoft.com/en-us/library/5sa98se7.aspx

comments powered by Disqus