C99 is now the C standard for all our C code.
The main new feature is mixed variable declarations and code, which can help reduce uninitialized variables or accidental variable reuse. Due to incomplete C99 support in VS 2013, variable length arrays are not supported, BLI_array_alloca must still be used. The header <tgmath.h> is also not supported. Differential Revision: https://developer.blender.org/D1631
This commit is contained in:
@@ -1189,12 +1189,6 @@ if(UNIX AND NOT APPLE)
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
set(PLATFORM_CFLAGS "-pipe -fPIC -funsigned-char -fno-strict-aliasing")
|
||||
|
||||
if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "5.0")
|
||||
# GCC5 uses gnu11, until we update, force c89
|
||||
# though some c11 features can still be used.
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu89")
|
||||
endif()
|
||||
|
||||
# use ld.gold linker if available, could make optional
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_C_COMPILER} -fuse-ld=gold -Wl,--version
|
||||
@@ -2577,9 +2571,9 @@ if(CMAKE_COMPILER_IS_GNUCC)
|
||||
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_CAST_ALIGN -Wcast-align)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_DECLARATION_AFTER_STATEMENT -Werror=declaration-after-statement)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE -Werror=return-type)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_VLA -Werror=vla)
|
||||
# system headers sometimes do this, disable for now, was: -Werror=strict-prototypes
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_STRICT_PROTOTYPES -Wstrict-prototypes)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_MISSING_PROTOTYPES -Wmissing-prototypes)
|
||||
@@ -2624,7 +2618,6 @@ if(CMAKE_COMPILER_IS_GNUCC)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_TYPE_LIMITS -Wtype-limits)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ERROR_RETURN_TYPE -Werror=return-type)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ERROR_DECLARATION_AFTER_STATEMENT -Werror=declaration-after-statement)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_CHAR_SUBSCRIPTS -Wno-char-subscripts)
|
||||
ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_UNKNOWN_PRAGMAS -Wno-unknown-pragmas)
|
||||
@@ -2661,7 +2654,6 @@ elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
|
||||
# strange, clang complains these are not supported, but then yses them.
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ALL -Wall)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_DECLARATION_AFTER_STATEMENT -Werror=declaration-after-statement)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_IMPLICIT_FUNCTION_DECLARATION -Werror=implicit-function-declaration)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_ERROR_RETURN_TYPE -Werror=return-type)
|
||||
ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_AUTOLOGICAL_COMPARE -Wno-tautological-compare)
|
||||
@@ -2776,6 +2768,13 @@ if(WITH_CPP11)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
# Visual Studio has all standards it supports available by default
|
||||
else()
|
||||
# Use C99 + GNU extensions, works with GCC, Clang, ICC
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
|
||||
endif()
|
||||
|
||||
# Include warnings first, so its possible to disable them with user defined flags
|
||||
# eg: -Wno-uninitialized
|
||||
set(CMAKE_C_FLAGS "${C_WARNINGS} ${CMAKE_C_FLAGS} ${PLATFORM_CFLAGS}")
|
||||
|
@@ -498,6 +498,13 @@ if env['WITH_BF_CPP11']:
|
||||
else:
|
||||
env['CXXFLAGS'].append('-std=c++11')
|
||||
|
||||
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
|
||||
# Visual Studio has all standards it supports available by default
|
||||
pass
|
||||
else:
|
||||
# Use C99 + GNU extensions, works with GCC, Clang, ICC
|
||||
env['CFLAGS'].append('-std=gnu99')
|
||||
|
||||
#check for additional debug libnames
|
||||
|
||||
if env.has_key('BF_DEBUG_LIBS'):
|
||||
|
@@ -248,7 +248,7 @@ REL_CXXFLAGS = []
|
||||
REL_CCFLAGS = ['-O2']
|
||||
|
||||
CC_WARN = ['-Wall']
|
||||
C_WARN = ['-Wno-char-subscripts', '-Wpointer-arith', '-Wcast-align', '-Wdeclaration-after-statement', '-Wno-unknown-pragmas', '-Wstrict-prototypes']
|
||||
C_WARN = ['-Wno-char-subscripts', '-Wpointer-arith', '-Wcast-align', '-Wvla', '-Wno-unknown-pragmas', '-Wstrict-prototypes']
|
||||
CXX_WARN = ['-Wno-invalid-offsetof', '-Wno-sign-compare']
|
||||
|
||||
##FIX_STUBS_WARNINGS = -Wno-unused
|
||||
|
@@ -254,7 +254,7 @@ REL_CFLAGS = []
|
||||
REL_CXXFLAGS = []
|
||||
REL_CCFLAGS = ['-O2']
|
||||
|
||||
C_WARN = ['-Wno-char-subscripts', '-Wdeclaration-after-statement', '-Wunused-parameter', '-Wstrict-prototypes', '-Werror=declaration-after-statement', '-Werror=implicit-function-declaration', '-Werror=return-type']
|
||||
C_WARN = ['-Wno-char-subscripts', '-Wvla', '-Wunused-parameter', '-Wstrict-prototypes', '-Werror=vla', '-Werror=implicit-function-declaration', '-Werror=return-type']
|
||||
CC_WARN = ['-Wall']
|
||||
CXX_WARN = ['-Wno-invalid-offsetof', '-Wno-sign-compare']
|
||||
|
||||
|
@@ -202,7 +202,7 @@ REL_CFLAGS = []
|
||||
REL_CXXFLAGS = []
|
||||
REL_CCFLAGS = ['-O2']
|
||||
|
||||
C_WARN = ['-Wno-char-subscripts', '-Wdeclaration-after-statement', '-Wstrict-prototypes']
|
||||
C_WARN = ['-Wno-char-subscripts', '-Wvla', '-Wstrict-prototypes']
|
||||
|
||||
CC_WARN = [ '-Wall' ]
|
||||
|
||||
|
@@ -197,7 +197,7 @@ REL_CXXFLAGS = []
|
||||
REL_CCFLAGS = ['-O2', '-ftree-vectorize']
|
||||
|
||||
# NOTE: C_WARN seems to get ignored - at least -Wno-char-subscripts doesn't work!
|
||||
C_WARN = ['-Wno-char-subscripts', '-Wdeclaration-after-statement', '-Wstrict-prototypes']
|
||||
C_WARN = ['-Wno-char-subscripts', '-Wvla', '-Wstrict-prototypes']
|
||||
|
||||
CC_WARN = [ '-Wall', '-Wno-char-subscripts' ]
|
||||
|
||||
|
@@ -30,6 +30,9 @@
|
||||
*/
|
||||
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
# ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wvla"
|
||||
# endif
|
||||
# define USE_DYNSIZE
|
||||
#endif
|
||||
|
||||
|
@@ -2055,7 +2055,7 @@ static PyObject *Matrix_richcmpr(PyObject *a, PyObject *b, int op)
|
||||
|
||||
static Py_hash_t Matrix_hash(MatrixObject *self)
|
||||
{
|
||||
float mat[SQUARE(MATRIX_MAX_DIM)];
|
||||
float mat[MATRIX_MAX_DIM * MATRIX_MAX_DIM];
|
||||
|
||||
if (BaseMath_ReadCallback(self) == -1)
|
||||
return -1;
|
||||
|
Reference in New Issue
Block a user