diff --git a/SConstruct b/SConstruct index 42e90851714..4a94cd8c3fe 100644 --- a/SConstruct +++ b/SConstruct @@ -189,6 +189,21 @@ if selected_platform in platform_list: detect.configure(env) + # Set our C and C++ standard requirements. + # Prepending to make it possible to override. + # This MSVC "detection" is an extreme hack. + is_msvc = (os.name=="nt") and (os.getenv("VSINSTALLDIR")!=None or os.getenv("VCINSTALLDIR")!=None) and (selected_platform in ["windows", "winrt"]) + if (not is_msvc): + # Specifying GNU extensions support explicitly, which are supported by both GCC and Clang. + # We don't support C++17 so stick to earlier standards. + # Godot 1.0 definitely started as a C++98 codebase. + env.Prepend(CFLAGS=["-std=gnu11"]) + env.Prepend(CXXFLAGS=["-std=gnu++98"]) + # Disable these auto-enabled warnings which are treated as errors by modern compilers. + env.Prepend(CCFLAGS=["-Wno-error=implicit-function-declaration", "-Wno-error=incompatible-pointer-types"]) + else: + # MSVC doesn't support setting C++ to pre-C++14 standards, so do nothing and hope it works. + pass flag_list = platform_flags[selected_platform] for f in flag_list: diff --git a/platform/android/detect.py b/platform/android/detect.py index 417f3e68ab1..bb21d0c3e2f 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -150,7 +150,7 @@ def configure(env): elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-D_DEBUG', '-g1', '-Wall', '-O0', '-DDEBUG_ENABLED']) + env.Append(CCFLAGS=['-D_DEBUG', '-g1', '-O0', '-DDEBUG_ENABLED']) env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) if env["armv6"] == "no" and env['x86'] != 'yes': diff --git a/platform/flash/detect.py b/platform/flash/detect.py index 5507ce5177d..48be88738bc 100644 --- a/platform/flash/detect.py +++ b/platform/flash/detect.py @@ -98,7 +98,7 @@ def configure(env): elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-D_DEBUG', '-g0', '-Wall', '-O0', '-DDEBUG_ENABLED']) + env.Append(CCFLAGS=['-D_DEBUG', '-g0', '-O0', '-DDEBUG_ENABLED']) env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) env.Append(CPPFLAGS=['-DFLASH_ENABLED', '-DGLES1_ENABLED', '-DNO_FCNTL', '-DUNIX_ENABLED']) diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py index 93345be7302..3b4f0c89e47 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -54,7 +54,7 @@ def configure(env): env['AR'] = 'ar' import string - #env['CCFLAGS'] = string.split('-arch armv7 -Wall -fno-strict-aliasing -fno-common -D__IPHONE_OS_VERSION_MIN_REQUIRED=20000 -isysroot $IPHONESDK -fvisibility=hidden -mmacosx-version-min=10.5 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\" -DNO_THUMB') + #env['CCFLAGS'] = string.split('-arch armv7 -fno-strict-aliasing -fno-common -D__IPHONE_OS_VERSION_MIN_REQUIRED=20000 -isysroot $IPHONESDK -fvisibility=hidden -mmacosx-version-min=10.5 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\" -DNO_THUMB') env['CCFLAGS'] = string.split('-fno-objc-arc -arch armv7 -fmessage-length=0 -fno-strict-aliasing -fdiagnostics-print-source-range-info -fdiagnostics-show-category=id -fdiagnostics-parseable-fixits -Wno-trigraphs -fpascal-strings -Wmissing-prototypes -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wunused-variable -Wunused-value -Wno-shorten-64-to-32 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS5.0.sdk -gdwarf-2 -fvisibility=hidden -Wno-sign-conversion -mthumb "-DIBOutlet=__attribute__((iboutlet))" "-DIBOutletCollection(ClassName)=__attribute__((iboutletcollection(ClassName)))" "-DIBAction=void)__attribute__((ibaction)" -miphoneos-version-min=4.3 -MMD -MT dependencies -isysroot $IPHONESDK') @@ -95,17 +95,17 @@ def configure(env): if (env["target"]=="release"): - env.Append(CCFLAGS=['-O3', '-ffast-math', '-DNS_BLOCK_ASSERTIONS=1','-Wall']) + env.Append(CCFLAGS=['-O3', '-ffast-math', '-DNS_BLOCK_ASSERTIONS=1']) env.Append(LINKFLAGS=['-O3', '-ffast-math']) elif env["target"] == "release_debug": - env.Append(CCFLAGS=['-Os', '-ffast-math', '-DNS_BLOCK_ASSERTIONS=1','-Wall','-DDEBUG_ENABLED']) + env.Append(CCFLAGS=['-Os', '-ffast-math', '-DNS_BLOCK_ASSERTIONS=1','-DDEBUG_ENABLED']) env.Append(LINKFLAGS=['-Os', '-ffast-math']) env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED']) elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-Wall', '-O0', '-DDEBUG_ENABLED']) + env.Append(CCFLAGS=['-D_DEBUG', '-DDEBUG=1', '-gdwarf-2', '-O0', '-DDEBUG_ENABLED']) env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ENABLED']) elif (env["target"]=="profile"): diff --git a/platform/isim/detect.py b/platform/isim/detect.py index 8d60e30d256..f1b8dae1199 100644 --- a/platform/isim/detect.py +++ b/platform/isim/detect.py @@ -51,7 +51,7 @@ def configure(env): env['AR'] = 'ar' import string - env['CCFLAGS'] = string.split('-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fasm-blocks -Wall -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -isysroot $ISIMSDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"') + env['CCFLAGS'] = string.split('-arch i386 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fmessage-length=0 -fpascal-strings -fasm-blocks -D__IPHONE_OS_VERSION_MIN_REQUIRED=40100 -isysroot $ISIMSDK -mios-simulator-version-min=4.3 -DCUSTOM_MATRIX_TRANSFORM_H=\\\"build/iphone/matrix4_iphone.h\\\" -DCUSTOM_VECTOR3_TRANSFORM_H=\\\"build/iphone/vector3_iphone.h\\\"') env.Append(LINKFLAGS=['-arch', 'i386', '-mios-simulator-version-min=4.3', @@ -84,7 +84,7 @@ def configure(env): elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-DDEBUG', '-D_DEBUG', '-gdwarf-2', '-Wall', '-O0', '-DDEBUG_ENABLED']) + env.Append(CCFLAGS=['-DDEBUG', '-D_DEBUG', '-gdwarf-2', '-O0', '-DDEBUG_ENABLED']) env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) elif (env["target"]=="profile"): diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index 845b2e3395a..621330d803a 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -70,7 +70,7 @@ def configure(env): env.Append(CCFLAGS=['-O2','-DDEBUG_ENABLED']) elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-D_DEBUG', '-Wall', '-O2', '-DDEBUG_ENABLED']) + env.Append(CCFLAGS=['-D_DEBUG', '-O2', '-DDEBUG_ENABLED']) env.Append(CPPFLAGS=['-DDEBUG_MEMORY_ALLOC']) env.Append(CPPFLAGS=["-fno-exceptions",'-DNO_SAFE_CAST','-fno-rtti']) diff --git a/platform/nacl/detect.py b/platform/nacl/detect.py index f8849cfd259..2acb59bb599 100644 --- a/platform/nacl/detect.py +++ b/platform/nacl/detect.py @@ -54,7 +54,7 @@ def configure(env): elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-g', '-O0', '-Wall','-DDEBUG_ENABLED']) + env.Append(CCFLAGS=['-g', '-O0', '-DDEBUG_ENABLED']) elif (env["target"]=="profile"): diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 1b32838525e..a8836d8f460 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -51,7 +51,7 @@ def configure(env): elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-g3', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) + env.Append(CCFLAGS=['-g3', '-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) if (env["freetype"]!="no"): diff --git a/platform/server/detect.py b/platform/server/detect.py index 24b36d31885..ebfc2a674f2 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -66,7 +66,7 @@ def configure(env): elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-g2', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) + env.Append(CCFLAGS=['-g2', '-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) env.Append(CPPFLAGS=['-DSERVER_ENABLED','-DUNIX_ENABLED']) env.Append(LIBS=['pthread','z']) #TODO detect linux/BSD! diff --git a/platform/windows/detect.py b/platform/windows/detect.py index be92ee8f6da..0b8e4b421a1 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -188,7 +188,7 @@ def configure(env): elif (env["target"]=="debug"): - env.Append(CCFLAGS=['-g', '-Wall','-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) + env.Append(CCFLAGS=['-g', '-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) if (env["freetype"]!="no"): env.Append(CCFLAGS=['-DFREETYPE_ENABLED'])