BaseCppCompilerDefaults.xcpjh
////////////////////////// Compiler //////////////////////////
@if (IsGccBasedCompiler)
{
/*
-g -O -Wall -Weffc++ -pedantic
-pedantic-errors -Wextra -Wall -Waggregate-return -Wcast-align
-Wcast-qual -Wchar-subscripts -Wcomment -Wconversion
-Wdisabled-optimization
-Werror -Wfloat-equal -Wformat -Wformat=2
-Wformat-nonliteral -Wformat-security
-Wformat-y2k
-Wimplicit -Wimport -Winit-self -Winline
-Winvalid-pch
-Wunsafe-loop-optimizations -Wlong-long -Wmissing-braces
-Wmissing-field-initializers -Wmissing-format-attribute
-Wmissing-include-dirs -Wmissing-noreturn
-Wpacked -Wpadded -Wparentheses -Wpointer-arith
-Wredundant-decls -Wreturn-type
-Wsequence-point -Wshadow -Wsign-compare -Wstack-protector
-Wstrict-aliasing -Wstrict-aliasing=2 -Wswitch -Wswitch-default
-Wswitch-enum -Wtrigraphs -Wuninitialized
-Wunknown-pragmas -Wunreachable-code -Wunused
-Wunused-function -Wunused-label -Wunused-parameter
-Wunused-value -Wunused-variable -Wvariadic-macros
-Wvolatile-register-var -Wwrite-strings
*/
/*
-Wno-invalid-offsetof (C++ and Objective-C++ only)
Suppress warnings from applying the 'offsetof' macro to a non-POD type.
According to the 1998 ISO C++ standard, applying 'offsetof' to a non-POD type is undefined. In
existing C++ implementations, however, 'offsetof' typically gives meaningful results even when
applied to certain kinds of non-POD types. (Such as a simple struct that fails to be a POD
type only by virtue of having a constructor.) This flag is for users who are aware that they
are writing nonportable code and who have deliberately chosen to ignore the warning about it.
The restrictions on 'offsetof' may be relaxed in a future version of the C++ standard.
*/
// todo: do we want -fexceptions?
+cpp
{
-std=c++1y
-g
-MMD
-fPIC
-Wall
-Wno-sign-compare
-Wno-unused-variable
-Wno-invalid-offsetof
-Wno-delete-non-virtual-dtor
@if (MaximumArchiveCompression)
{
-DMAXIMUM_ARCHIVE_COMPRESSION
}
}
+cpp("Debug")
{
-O0
-D_DEBUG -DDEBUG
}
+cpp("Release")
{
-O2
-DNDEBUG
}
+cpp("Console Application")
{
-D_CONSOLE
}
+cpp("Static Library")
{
-D"$(PROJNAME)_STATIC_LIBRARY"
}
}
@if ("$(COMPILER)" == "winegcc")
{
+cpp
{
-Wno-unused-but-set-variable
-mwindows
//-fshort-wchar
-D_CRT_SECURE_NO_DEPRECATE
-D_WINDOWS
-D_WINDLL
-DWIN32
-D_WIN32_WINNT=0x0501
}
}
@if ("$(COMPILER)" == "gcc")
{
+cpp
{
-Wno-unused-but-set-variable
}
}
@if ("$(COMPILER)" == "clang")
{
+cpp
{
-stdlib=libc++ -Wno-logical-op-parentheses -Wno-reorder
}
}
@if (IsiOSSimPlatform)
{
+cpp
{
-arch i386
-miphoneos-version-min=6.1
-fvisibility=hidden
-fvisibility-inlines-hidden
-isysroot "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator10.0.sdk/"
}
}
@if (IsiOSPlatform)
{
+cpp
{
//-arch armv6
//-arch armv7
//-arch armv7s
-arch arm64
-miphoneos-version-min=6.1
-isysroot "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS10.0.sdk/"
-fvisibility=hidden
-fvisibility-inlines-hidden
//-mthumb
//-finline-functions
//-ftemplate-depth-128
//-gdwarf-2
//-fexceptions
//-pthread
//-fmessage-length=0
}
}
@if (IsMacOSXPlatform)
{
+cpp
{
-arch x86_64
//-mmacosx-version-min=10.7
//-fvisibility-inlines-hidden
}
}
@if (IsMsvcCompiler)
{
+cpp
{
/nologo
/MP // Use multiple processors to compile files. Incompatible with /Gm
/D "_CRT_SECURE_NO_DEPRECATE"
/D "_SCL_SECURE_NO_WARNINGS" // Disable C4996 level 3 warnings when call potentially unsafe methods in the C++ standard library
/W3 // Warning level 3
/Zm500 // Sets the compiler's memory allocation limit
/Yu"StdAfx.h" // Compile using pch through StdAfx.h
/Zi // Produces a program database (PDB) that contains type information and symbolic
// debugging information for use with the debugger. The symbolic debugging information
// includes the names and types of variables, as well as functions and line numbers.
/I "$(VIRTUAL_TREE)"
/Fp"./$(PLATFORM)/$(CONFIG)/$(PROJNAME)/$(PROJNAME).pch"
/Fo"./$(PLATFORM)/$(CONFIG)/$(PROJNAME)/"
/Fd"./$(PLATFORM)/$(CONFIG)/$(PROJNAME)/"
/EHsc // The exception-handling model where both
// 1) a catch block will not catch asynchronous (structured) exceptions
// [This gives better performance because the compiler can optimise
// a catch block more aggressively]
// 2) the compiler assumes extern C functions never throw exceptions.
@if (MaximumArchiveCompression)
{
/D "MAXIMUM_ARCHIVE_COMPRESSION"
}
}
// This was added to avoid a warning in VS2010
// This occurs when build all using devenv, and then later compile individual files with xcpp
// Warning C4652 : Compiler option CDecl(/Gd) inconsistent with precompiled header.
// This even occurs for x64 builds!
+cpp //("Win32")
{
// /Gd is only available in the compiler targeting x86; it is not available in the compilers
// targeting x64 or Itanium.
// /Gd is the default setting. It specifies the C calling convention for all functions except
// C++ member functions and functions marked __stdcall or __fastcall.
/Gd
}
// Utility Projects and console applications don't define _WINDOWS
+cpp("Application", "Static Library", "Dynamic-Link Library")
{
/D "_WINDOWS"
}
+cpp("Console Application")
{
/D "_CONSOLE"
}
+cpp("Dynamic-Link Library")
{
/D "_WINDLL"
/D "$(PROJNAME)_EXPORTS"
}
/*
MFC DLS
-------
Kind of DLL Compiler options Preprocessor defines Linker
-------------------------------------------------------------------------------------------------------------------------------------------------------
Regular DLL, static
linked to MFC /MT or /MTd _WINDOWS, WIN32, _WINDLL, _USRDLL /subsystem:windows /machine:I386
Regular DLL, dynamic
linked to MFC /ML or /MLd _WINDOWS, WIN32, _WINDLL, _USRDLL, _AFXDLL /subsystem:windows /machine:I386
Extension DLL /MD or /MDd _WINDOWS, WIN32, _WINDLL, _AFXDLL, _AFXEXT /subsystem:windows /machine:I386
MFC windows exe _WINDOWS, WIN32 /subsystem:windows /machine:I386
*/
+cpp("MFC")
{
/*
todo: there are rules for when the following should be applied to MFC projects
*/
// Determine which decarations are pulled in from the MFC header files
// Indicates regular MFC DLL (either static linked or dynamic linked to the MFC dlls)
// Not defined for an MFC extension DLL.
/D "_USRDLL"
/D "_WINDLL" // A Windows DLL
/D "_AFXDLL" // Dynamic linked to the MFC DLLs
/D "_AFXEXT" // An extension DLL
}
/*
Character set
-------------
SBCS = Single byte character set
MBCS = Multibyte-character set. MBCS is used to describe all non-Unicode support for multibyte characters.
In Visual C++, MBCS always means DBCS. Character sets wider than 2 bytes are not supported.
DBCS = Double-byte character set. DBCS characters are composed of 1 or 2 bytes. DBCS is a form of MBCS.
Unicode
Cannot run on windows 95, windows 98. There are Unicode versions of MFC.
Define the symbol _UNICODE (instead of _MBCS)
wchar_t : wide character (16 bit)
L"Hello" : wide character string literal
Generic Text Mappings using TCHAR.H
-----------------------------------
Make string literals portable using the _T macro.
(SBCS) _MBCS _UNICODE
---------------------------------------------------------------
_TCHAR char char wchar_t
_T L
_TEOF EOF EOF WEOF
_tcscpy strcpy _mbscpy wcscpy
_tcsclen strlen _mbslen wcslen
tcscat strcat _mbscat wcscat
_tprintf printf printf wprintf
*/
general("MBCS")
{
// Defines whether _UNICODE or _MBCS should be set. Also affects the linker entry point where appropriate.
// 0 = Not set
// 1 = Use UniCode Character Set
// 2 = Use Multi Byte Character Set
CharacterSet = "2"
}
+cpp("MBCS")
{
/D "_MBCS"
}
general("Unicode")
{
// Defines whether _UNICODE or _MBCS should be set. Also affects the linker entry point where appropriate.
// 0 = Not set
// 1 = Use UniCode Character Set
// 2 = Use Multi Byte Character Set
CharacterSet = "1"
}
+cpp("Unicode")
{
/D "_UNICODE"
/D "UNICODE"
}
+cpp("Win32", "x64")
{
/D "WIN32"
/*
0x0500 Windows 2000
0x0501 Windows XP
0x0502 Windows Server 2003
0x0600 Windows Vista
0x0601 Windows 7
*/
/D "_WIN32_WINNT=0x0501" // Target Windows XP
/fp:precise
}
+cpp("WinCE")
{
/Os // Favor code space
/D "_WIN32_WCE=0x420"
/D "UNDER_CE"
/D "WINCE"
/D "WINDOWSCE_DLL_EXPORTS"
/D "ARM"
/D "_ARM_"
/D "_WINDLL"
/GR // Enable run-time type information (RTTI)
// Note that when create a new WinCE app with the VC wizard
// RTTI is disabled by default with /GR-
/fp:fast // Creates the fastest floating point code in the majority of cases
}
+cpp("Pocket PC 2003 (ARMV4)")
{
/D "WIN32_PLATFORM_PSPC"
}
+cpp("Smartphone 2003 (ARMV4)")
{
/D "WIN32_PLATFORM_WFSP"
}
+cpp("Release")
{
/O2 // Maximize speed
/Ot // Optimisation = Create fast code
/FD // Generate file dependencies
// VC adds this switch into the release build implicitly.
@if (EnableSecureSCL)
{
/D "_SECURE_SCL=1"
}
@else
{
/D "_SECURE_SCL=0"
}
/D "NDEBUG"
}
+cpp("Debug")
{
/Od // Disable optimisation
///Gm // Minimal rebuild
// Detect changes to C++ class definitions and recompile only affected source files
/D "_DEBUG"
/D "DEBUG"
/RTC1 // Enables stack frame run-time error checking,
// Reports when a variable is used without having been initialized
// Incompatible with any optimisation other than debug
}
@if (UseStaticCRT)
{
+cpp("Release|Win32", "Release|x64")
{
/MT // Run time library = static Multi-threaded library
}
+cpp("Debug|Win32", "Debug|x64")
{
/MTd // Run time library = debug version of static Multi-threaded library
}
}
@else
{
+cpp("Release|Win32", "Release|x64")
{
/MD // Run time library = Multi-threaded DLL
}
+cpp("Debug|Win32", "Debug|x64")
{
/MDd // Run time library = Multi-threaded debug DLL
}
}
+cpp("Release|WinCE")
{
/MT // Run time library = static Multi-threaded library
}
+cpp("Debug|WinCE")
{
/MTd // Run time library = debug version of static Multi-threaded library
}
/*
+cpp("VC6")
{
/GR // Enable RTTI
/GX // Enables synchronous exception handling
/FD // Generate file dependencies
/GF // String pooling
/c
}
+cpp("VC6|Debug")
{
/GZ // Catch release-build errors in debug build
}
*/
}
/*
To enable the Visual Leak Detector:
- Download and install version v2.4rc2 from http://vld.codeplex.com/releases
- Add the following to an appropriate xcpp file (e.g. build_local.xcpp or machine_local.xcpp)
@def+ bool UseVisualLeakDetector = true
- Add
#ifdef CEDA_USING_VISUAL_LEAK_DETECTOR
#include <vld.h>
#endif
to the cpp file which defines main/WinMain/DllMain of each library or exe
*/
@if (IsWindowsPlatform && UseVisualLeakDetector)
{
+cpp
{
/I "C:/Program Files (x86)/Visual Leak Detector/include"
/D "CEDA_USING_VISUAL_LEAK_DETECTOR"
}
+link("Win32")
{
/LIBPATH:"C:/Program Files (x86)/Visual Leak Detector/lib/Win32"
}
+link("x64")
{
/LIBPATH:"C:/Program Files (x86)/Visual Leak Detector/lib/Win64"
}
}