Skip to content

Instantly share code, notes, and snippets.

@gianmaria
Last active June 7, 2025 20:22
Show Gist options
  • Save gianmaria/729d66a0802125b4329117089e97550b to your computer and use it in GitHub Desktop.
Save gianmaria/729d66a0802125b4329117089e97550b to your computer and use it in GitHub Desktop.
msvc common compiler flags
// complete list: https://learn.microsoft.com/en-us/cpp/build/reference/compiler-options-listed-by-category
/Od -> debug
/Zi -> debug info in pdb
/Wall -> enable all warnings
/external:anglebrackets /external:W0 /analyze:external- -> disable warnings for external header
/wdnnnn -> disable specific warning
/EHsc -> Full compiler support for the Standard C++ exception handling (exceptions can only occur at a throw statement or at a function call and functions declared as extern "C" never throw a C++ exception).
/std:c++latest -> set c++ standard
/Zc:__cplusplus -> enables the __cplusplus preprocessor macro to report an updated value for recent C++ language standards support.
/utf-8 -> Set source and execution character sets to UTF-8.
/D "_CONSOLE" /D "_UNICODE" /D "UNICODE" -> defines macro
/I -> add dir to include path
/Gm- -> disable minimal rebuild
/GS -> enable Buffer Security Check
/GL -> enable Whole Program Optimization
/WX- -> disable treating warnings as errors
/Fe: -> Renames the executable file.
/Fd: -> Rename the program database file.
/Fo: -> Rename the object file (obj).
/MDd -> Use the debug multithread, DLL-specific version of the run-time library.
/MTd -> Use the debug multithread, static version of the run-time library
/MD -> Use the release multithread, DLL-specific version of the run-time library
/MT -> Use the release multithread, static version of the run-time library
/FC -> Displays the full path of source code files passed to cl.exe in diagnostic text.
/link -> Passes the specified option to LINK.
/SUBSYSTEM:CONSOLE
/LIBPATH:C:\ -> add folder to lib path
/DEBUG -> creates a debugging information file for the executable.
example:
cl /FC /std:c++20 /EHsc ^
/IC:\Dev\vcpkg\installed\x64-windows\include ^
/DDEBUG ^
/Wall ^
/wd4668 /wd4820 /wd5039 /wd5045 ^
/Zi /Od ^
/Fe:out\debug\hello.exe /Fd:out\debug\hello.pdb /Fo:out\debug\hello.obj ^
/MDd ^
main.cpp ^
/link ^
/LIBPATH:C:\Dev\vcpkg\installed\x64-windows\debug\lib ^
libcurl-d.lib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment