Notes about the compiler flags which the MicroSoft C compiler assigns when the IDE is in debug mode

compiler flags Documentation about compiler flags for the Micorosoft C compiler.
A mirror copy of the documentation.

This is the typical compile line for the Microsoft IDE in debug mode:
/Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_UNICODE" /D "UNICODE" /Gm /EHsc /RTC1 /MDd /Yu"stdafx.h" /Fp"Debug\hello.pch" /Fo"Debug\\" /Fd"Debug\vc80.pdb" /W3 /nologo /c /Wp64 /ZI /TP /errorReport:prompt

So what does this all mean?

UNICODE

_UNICODE and UNICODE cause the input strings to be interpretated as Unicode, rather than 8bit asci so the ide changes the ANSI standard
The ide changes the ANSI standard
int main( int argc, char* argv[])
to the Microsoft standard
int _tmain( int argc, _TCHAR* argv[])
the header file tchar.h uses the macro _UNICODE to define the macros _tmain and _TCHAR. If _UNICODE then _TCHAR is typedefed to wchar_t, and _tmain to wmain. If _UNICODE is not defined then _TCHAR is typedefed to char, and _tmain is defined to main, which is the normal ansi standard.

Many text functions, such as WriteConsoleOutput, are defined according to _UNICODE. Ralf McArdell has written a nice article about this. Here is a mirror of the article.

_DEBUG

_DEBUG and NDEBUG are mutually exclusive macros, _DEBUG means debugging is on, NDEBUG means debugging is off.

_CONSOLE

. _CONSOLE means the output is a console application

/Gm

/Gm - enable minimal rebuild

/EHsc

/EHsc = /EHs + /EHc = Use exceptions, but not structured exceptions, and warn if an extern "C" function uses an exception.

/EHs

/EHs - enable C++ style exceptions (EH), don't use SEH Structured Exception Handling

/EHa

/EHa - enable EH exceptions, and use SEH to do it, this is mutually exclusive with /EHs
Don't use /EHa unless you wan't code that is non standard, non portable and potentially non forard compatible.
It uses non standard keywords like __try, __except, __finally and __leave.
SEH is an abomination . Here is a mirror of the horror.
And here is an article from the Microsoft Journal, and its mirror here.

/EHc

/EHc - extern "C" defaults to no throw. If an extern "C" function has a throw statement, then it will generate a benign warning.

/RTc1

/RTC1 means, "give me a lot of compiler warnings and run time warnings about data".
/RTC1 is the same as /GZ or /RTcsu.
/RTCcsu = /RTc + /Rts + /RTu
See the following for these three types of run time warnings.

/RTc

/RTc - Reports when a value is assigned to a smaller data type and results in a data loss. For example, if a value of type short 0x101 is assigned to a variable of type char.

/RTs

/RTs - Enables stack frame run-time error checking, as follows:
Initialization of local variables to a nonzero value. This helps identify bugs that do not appear when running
Detection of overruns and underruns of local variables such as arrays.
Stack pointer verification, which detects stack pointer corruption.

/RTu or /RTCu ?

I had a hard time finding clear documentation about this. I thinks this is the same as /RTCu which means check for unitialized local variables being used. I suspect this must really *slow* down execution of the code.

/MDd

/MDd link with MXVCRTD.lib = debug library. This must also really slow down execution of prorams, because the debug memory allocators call _memset, to intialize all allocated memory to 0.

/Yu"stdafx.h"

/Yu"stdafx.h" - use a PCH, "Pre Compiled Header" file

/Fp"Debug\hello.pch"

/Fp"Debug\hello.pch" - names precompiled header file output

/Fo"Debug\\"

/Fo"Debug\\" - Put object files in Debug directory

/Fd"Debug\vc80.pdb"

/Fd"Debug\vc80.pdb" - name of debuging information database. You can read about this (bad) idea here or at the mirror. This database makes it difficult to port compiled and linked code between machines because you always have to include the database, and because the database makes references to the directory try, which are not at all clear. I suspect this capability slows the execution of the code.

/W3

/W3 - set to warning level 3 = lots of warnings.
Do you really need to be reminded that microsoft hates sprintf, fopen and all the ansi (non microsoft) functions?

/nologo

/nologo suppress copyright message

/c

/c compile only don't link

/Wp64

/Wp64 enable 64 bit porting warnings

/ZI

/ZI enable edit and continue debug info -- this has to be *slow*

/TP

/TP compile all files as C++ files, even C files

/errorReport:prompt

/errorReport:prompt prompt user before sending internal compiler errors to Msft
Do you think anyone actually reads the reports? There are still bugs in the precompiler dating back to 1995.