Compiler switches can be incrementally added (using +cpp) or removed (with -cpp) in a top to bottom reading of the .xcpj file. For example:
+cpp
{
/nologo /W3 /Zm500 /Zi /EHsc
/D "_CRT_SECURE_NO_DEPRECATE"
/Yu"StdAfx.h"
/Fp"./$(PLATFORM)/$(CONFIG)/$(PROJNAME)/
$(PROJNAME).pch"
/Fo"./$(PLATFORM)/$(CONFIG)/$(PROJNAME)/"
/Fd"./$(PLATFORM)/$(CONFIG)/$(PROJNAME)/"
}
+cpp("Application", "Static Library", "Dynamic-Link Library")
{
/D "_WINDOWS"
}
+cpp("Console Application")
{
/D "_CONSOLE"
}
+cpp("Static Library", "Dynamic-Link Library")
{
/D "_WINDLL"
/D "$(PROJNAME)_EXPORTS"
}
+cpp("MBCS")
{
/D "_MBCS"
}
+cpp("Unicode", "WinCE")
{
/D "_UNICODE" /D "UNICODE"
}
+cpp("Win32")
{
/fp:precise /D "WIN32"
}
+cpp("WinCE")
{
/Os /GR /fp:fast
/D "_WIN32_WCE=0x420"
/D "UNDER_CE"
/D "WINCE"
/D "WINDOWSCE_DLL_EXPORTS"
/D "ARM"
/D "_ARM_"
/D "_WINDLL"
}
+cpp("Pocket PC 2003 (ARMV4)")
{
/D "WIN32_PLATFORM_PSPC"
}
+cpp("Smartphone 2003 (ARMV4)")
{
/D "WIN32_PLATFORM_WFSP"
}
+cpp("Release")
{
/Ot /FD /D "NDEBUG"
}
+cpp("Debug")
{
/Od /Gm /RTC1
/D "_DEBUG" /D "DEBUG"
}
+cpp("Release|Win32") { /MD }
+cpp("Debug|Win32") { /MDd }
+cpp("Release|WinCE") { /MT }
+cpp("Debug|WinCE") { /MTd }
The compiler switches are additive, making it easy to put common switches in a imported file.
Note the following:
For each project it’s implicit that the following are in the additional include paths:
Additional directories can be added to the include paths using the /I switch. For example:
+cpp
{
/I "$(VIRTUAL_TREE)"
/I "c:/dev/boost"
}
A path is absolute or else relative to the build directory. If a path begins with $(VIRTUAL_TREE), then a special kind of macro substitution is performed, where the whole path is repeated such that the prefix $(VIRTUAL_TREE) is replaced by the path to each physical root specified in the virtual tree in turn.
General
-------
// Comma separated list. /I "x"
string AdditionalIncludeDirectories;
[todo: Resolve #using References]
// 0 Disabled
// 1 /Z7 Generates C 7.0 compatible debugging information
// 3 /Zi Generates complete debugging information
// 4 /ZI Includes debug information in a program database compatible with Edit and Continue.
int DebugInformationFormat;
// /nologo
bool SuppressStartupBanner;
// /W0 /W1 /W2 /W3 /W4
int WarningLevel;
// /Wp64
bool Detect64BitPortabilityProblems;
// /WX
bool WarnAsError;
Optimization
------------
/Od Disables optimization (also throws Oi- Oy- Ob0 GF-)
/Os turns on optimization, favoring size (also throws Oy Ob2 GF)
/Ot now turns on optimization, favoring speed (also throws Oi Oy Ob2 GF)
/O1 has exactly the same meaning as Os
/O2 has exactly the same meaning as Ot
/Ox has exactly the same meaning as Ot
/Oi Enable intrinsic functions
/Op Improve floating point consistency
/GL Enable link time code generation
--------------
// 0 Disable /Od
// 1 Creates small code /O1
// 2 Creates fast code /O2
// 3 Uses maximum optimization /Ox
// 4 Custom
int Optimization;
// 0 default
// 1 Only __inline /Ob1
// 2 Any suitable /Ob2
int InlineFunctionExpansion;
// /Oi
bool EnableIntrinsicFunctions;
// /Op
bool ImproveFloatingPointConsistency;
// 0 Neither
// 1 Favor fast code /Ot
// 2 Favor small code /Os
int FavorSizeOrSpeed;
// /Oy
bool OmitFramePointers;
// /GT
bool EnableFiberSafeOptimizations;
// /GL
bool WholeProgramOptimization;
Preprocessor
------------
// Semicolon separated list. /D "x"
string PreprocessorDefinitions;
// /X
bool IgnoreStandardIncludePath;
// 0 No
// 1 With line numbers /P
// 2 Without line numbers /EP /P
int GeneratePreprocessedFile;
// /C
bool KeepComments;
Code generation
---------------
// /GF
// Pool strings into read only page of memory
bool StringPooling;
// /Gm
bool MinimalRebuild;
// 0 No
// 1 Yes /EHsc
// 2 Yes with SEH Exceptions /EHa
int ExceptionHandling;
// /RTCc
bool SmallerTypeCheck;
// 0 Default
// 1 Stack frames /RTCs
// 2 Uninitialised variables /RTCu
// 3 Both /RTC1 (equiv to /RTCsu)
int BasicRuntimeChecks;
// 0 Multi-threaded /MT
// 1 Multi-threaded debug /MTd
// 2 Multi-threaded DLL /MD
// 3 Multi-threaded debug DLL /MDd
int RuntimeLibrary;
// 0 Default
// 1 1 Byte /Zp1
// 2 2 Byte /Zp2
// 3 4 Byte /Zp4
// 4 8 Byte /Zp8
// 5 16 Byte /Zp16
int StructMemberAlignment;
// No = /GS- (on by default)
bool BufferSecurityCheck;
// /Gy
bool EnableFunctionLevelLinking;
// 0 Not Set
// 1 Streaming SIMD Extensions /arch:SSE
// 2 Streaming SIMD Extensions 2 /arch:SSE2
int EnableEnhancedInstructionSet;
// 0 Precise /fp:precise
// 1 Strict /fp:strict
// 2 Fast /fp:fast
int FloatingPointModel;
// /fp:except[-]
bool FloatingPointExceptions;
Language
--------
// /Za
bool DisableLanguageExtensions;
// /J
bool DefaultCharIsUnsigned;
// No = /Zc:wchar_t-
bool TreatWChar_tAsBuiltInType;
// No = /Zc:forScope-
bool ForceConformanceInForLoopScope;
// No = /GR- (enabled by default)
// Enable run-time type information (RTTI)
bool RuntimeTypeInfo;
// /openmp
bool OpenMP;
Precompled Headers
------------------
// 0 Not Using Precompiled Headers
// 1 Create Precompiled header /Yc"StdAfx.h"
// 2 Use Precompiled Header /Yu"StdAfx.h"
int UsePrecompiledHeader;
// "StdAfx.h"
string PrecompiledHeaderThrough;
// ".\Debug/cxUtils/cxUtils.pch" /Fpfilename
string PrecompiledHeaderFile;
Output Files
------------
// /Fx
bool ExpandAttributedSource;
// 0 No Listing
// 1 Assembly-Only Listing; .asm /FA
// 2 Assembly, Machine Code and Source; .cod /FAcs
// 3 Assembly With Machine Code; .cod /FAc
// 4 Assembly With Source Code; .asm /FAs
int AssemblerOutput;
// ".\Debug/cxUtils/"
string AssemblerListingLocation;
// ".\Debug/cxUtils/" /Fofilename
string ObjectFile;
// ".\Debug/cxUtils/"
string ProgramDataBaseFileName;
// /doc
bool GenerateXMLDocumentationFiles;
Browse Information
------------------
// 0 None
// 1 Include All Browse Information /FR
// 2 No Local Symbols /Fr
int BrowseInformation;
// todo: Browse file
Advanced
--------
// 0 __cdecl /Gd
// 1 __fastcall /Gr
// 2 __stdcall /Gz
int CallingConvention;
// 0 Default
// 1 Compile as C Code /TC
// 2 Compile as C++ Code /TP
// Select compile language option for .c and .cpp files.
int CompileAs;
// /wd
// Disable the desired warning numbers; put numbers in a semi-colon delimited list.
string DisableSpecificWarnings;
// /FI[name]
// Specifies one or more forced include files in a semi-colon delimited list.
string ForcedIncludeFiles;
// /showIncludes
// Generates a list of include files with compiler output
bool ShowIncludes;
// /U[macro]
// Specfies one or more preprocessor undefines
string UndefinePreprocessorDefinitions;
// /u
// Undefine all previously defined preprocessor values
bool UndefineAllPreprocessorDefinitions;
// /FC
bool UseFullPaths;
// /ZI
// [Removes default library name from .OBJ file]
bool OmitDefaultLibName;
// 0 Default
// 1 Prompt Immediately /errorReport:prompt
// 2 Queue For Next Login /errorReport:queue
int ErrorReporting;
// 0 ARM4 /QRarch4
// 1 ARM5 /QRarch5
// 2 ARM4T /QRarch4t
// 3 ARM5T /QRarch5t
// Sets the Instruction Set Architecture to compile for
int CompileForArchitecture;
// /QRinterwork (Interwork ARM and ARM Thumb Calls)
// Enabled generation of thunking code to interwork 16 and 32 bit ARM code.
bool InterworkCalls;
// /QRfpe
// Enables floating point emulation when generating code
bool EnableFloatingPointEmulation;
Other
-----
// /Zm500 [Sets the compiler's memory allocation limit]
string AdditionalOptions;
More notes on compiler switches
-------------------------------
/Gs[size] size = number of bytes that local variables can occupy before a stack probe is activated
/clr- This corresponds to not using CLR functionality at all. It is the default.
/clr: This tells the compiler to enable CLR funcationality, using the new syntax, and to
produce a mixed executable image (one that can contain both machine code and MSIL). Object files
generated from this mode can be linked with object files compiled with the clr- mode.
/clr:oldSyntax: This tells the compiler to enable CLR functionality, using the old managed syntax,
and to produce a mixed executable image.
/clr:pure: This tells the compiler to enable CLR functionality and to produce a pure executable
image (one that contains only MSIL).
/clr:safe: This tells the compiler to enable CLR functionality, to produce a pure executable image,
and to only allow verifiable source code through the compiler.
/Tc filename Specifies that filename is a C source file, even if it does not have a .c extension
/Tp filename Specifies that filename is a C++ source file, even if it doesn't have a .cpp or .cxx extension.
/TC global version of /Tc
/TP global version of /Tp
/MD Causes your application to use the multithread- and DLL-specific version of the run-time library.
Defines _MT and _DLL and causes the compiler to place the library name MSVCRT.lib into the
.obj file.
/favor:AMD64
/favor:Pentium4
/favor:EM64T
/favor:blend
Switches to avoid
-----------------
YX automatically use pch, but slows down the build!!!
Wp64 ignored
Gf particularly bad since it pools string literals into a writable section of memory.
[removed from Visual C++ 2005]
H places a maximum length on external names, achieved by just truncating the names.
Oa, Ow give the compiler the freedom to make assumptions about memory aliasing that are often
untrue
[removed from Visual C++ 2005]
G3 favour 386 [now ignored]
G4,G5,G6,G7 Now ignored
QIfdiv Relates to Pentium division bug
TO, To Consider unknown files as object files
Predefined macros
-----------------
/J --> _CHAR_UNSIGNED
/MACHINE:X86 --> _M_IX86
C++ file --> __cplusplus
/LDd, /MDd, /MLd, /MTd --> _DEBUG
/MD or /MDd --> _DLL
/f --> _FAST
/GD --> _WINDLL
/GA, /Gw, /GW, /Mq, /GD --> _WINDOWS
/MD, /MDd, /MT, or /MTd --> _MT
/GR --> _CPPRTTI
/clr --> _MANAGED
(always) --> _WIN32
/Ze --> _MSC_EXTENSIONS
/Zc:wchar_t or typedef --> _WCHAR_T_DEFINED, _NATIVE_WCHAR_T_DEFINED
/RTC[...] --> __MSVC_RUNTIME_CHECKS
Compiler _MSC_VER
-------- --------------
C Compiler version 6.0 600
C/C++ compiler version 7.0 700
Visual C++, Windows, version 1.0 800
Visual C++, 32-bit, version 1.0 800
Visual C++, Windows, version 2.0 900
Visual C++, 32-bit, version 2.x 900
Visual C++, 32-bit, version 4.0 1000
Visual C++, 32-bit, version 5.0 1100
Visual C++, 32-bit, version 6.0 1200
VS2010 1500
Examples of min _WIN32_WINNT for different APIs
-----------------------------------------------
0x0400
------
CreateFiber CreateFiberEx DeleteFiber ConvertThreadToFiber ConvertThreadToFiberEx
SetThreadIdealProcessor
TryEnterCriticalSection
SignalObjectAndWait
FindFirstFileEx
CopyFileEx
0x0403
------
InitializeCriticalSectionAndSpinCount
InitializeCriticalSectionEx
SetCriticalSectionSpinCount
0x0500 (Windows 2000)
------
AcceptEx, WSARecv, WSASend, TransmitFile, GetAcceptExSockaddrs
EnterCriticalSection
GetModuleHandleEx
0x0501 (Windows XP)
------
ConnectEx, DisconnectEx, TransmitPackets
LoadLibrary LoadLibraryEx GetProcAddress LoadModule
GetProcessHandleCount
ConvertFiberToThread
GetThreadIOPendingFlag
CheckRemoteDebuggerPresent
SetFileValidData
GetSystemRegistryQuota GetSystemTimes
GetNativeSystemInfo
CreateMemoryResourceNotification
GetSystemWow64Directory
CheckNameLegalDOS8Dot3
0x0502
------
GetDllDirectory SetDllDirectory
InterlockedCompareExchange64 InterlockedAnd64 InterlockedOr64 InterlockedXor64 InterlockedIncrement64 InterlockedDecrement64 InterlockedExchange64 InterlockedExchangeAdd64
GetThreadId
SetSystemFileCacheSize GetSystemFileCacheSize
NeedCurrentDirectoryForExePath
ReOpenFile
0x0600 (Windows Vista)
------
CancelIOEx
IsThreadAFiber
FlushProcessWriteBuffers QueryThreadCycleTime QueryProcessCycleTime QueryIdleProcessorCycleTime GetLongPathNameTransacted
GetQueuedCompletionStatusEx
SetFileCompletionNotificationModes
SetFileIoOverlappedRange
SetStdHandleEx
CreateMutexEx CreateEventEx CreateSemaphoreEx CreateWaitableTimerEx
CreateFileMappingNuma
QueryFullProcessImageName
CreateDirectoryTransacted RemoveDirectoryTransacted GetFullPathNameTransacted CreateFileTransacted SetFileAttributesTransacted ZGetFileAttributesTransacted GetCompressedFileSizeTransacted
DeleteFileTransacted FindFirstFileTransacted