forked from bartvdbraak/blender
patch [#33331] Time To Start Moving To Stdbool
by Lawrence D'Oliveiro (ldo) so BKE_utildefines.h allows use of C99's bool type and true/false. currently scons wont try to use stdbool.h, and works as if its never found.
This commit is contained in:
parent
e4f65749f9
commit
80ff313495
@ -149,6 +149,9 @@ mark_as_advanced(WITH_HEADLESS)
|
||||
option(WITH_AUDASPACE "Build with blenders audio library (only disable if you know what you're doing!)" ON)
|
||||
mark_as_advanced(WITH_AUDASPACE)
|
||||
|
||||
option(WITH_BOOL_COMPAT "Continue defining \"TRUE\" and \"FALSE\" until these can be replaced with \"true\" and \"false\" from stdbool.h" ON)
|
||||
mark_as_advanced(WITH_BOOL_COMPAT)
|
||||
|
||||
|
||||
# (unix defaults to OpenMP On)
|
||||
if((UNIX AND NOT APPLE) OR (MINGW))
|
||||
@ -264,7 +267,6 @@ mark_as_advanced(WITH_CXX_GUARDEDALLOC)
|
||||
option(WITH_ASSERT_ABORT "Call abort() when raising an assertion through BLI_assert()" OFF)
|
||||
mark_as_advanced(WITH_ASSERT_ABORT)
|
||||
|
||||
|
||||
if(APPLE)
|
||||
cmake_minimum_required(VERSION 2.8.8)
|
||||
cmake_policy(VERSION 2.8.8)
|
||||
@ -423,6 +425,13 @@ endif()
|
||||
|
||||
TEST_SSE_SUPPORT(COMPILER_SSE_FLAG COMPILER_SSE2_FLAG)
|
||||
|
||||
TEST_STDBOOL_SUPPORT()
|
||||
if(HAVE_STDBOOL_H)
|
||||
add_definitions(-DHAVE_STDBOOL_H)
|
||||
endif()
|
||||
if(WITH_BOOL_COMPAT)
|
||||
add_definitions(-DWITH_BOOL_COMPAT)
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Check for valid directories
|
||||
@ -2137,3 +2146,8 @@ if(FIRST_RUN)
|
||||
|
||||
message("${_config_msg}")
|
||||
endif()
|
||||
|
||||
# debug
|
||||
message(
|
||||
STATUS "HAVE_STDBOOL_H = ${HAVE_STDBOOL_H}"
|
||||
)
|
||||
|
@ -373,9 +373,10 @@ if btools.ENDIAN == "big":
|
||||
else:
|
||||
env['CPPFLAGS'].append('-D__LITTLE_ENDIAN__')
|
||||
|
||||
# TODO, make optional
|
||||
# TODO, make optional (as with CMake)
|
||||
env['CPPFLAGS'].append('-DWITH_AUDASPACE')
|
||||
env['CPPFLAGS'].append('-DWITH_AVI')
|
||||
env['CPPFLAGS'].append('-DWITH_BOOL_COMPAT')
|
||||
|
||||
# lastly we check for root_build_dir ( we should not do before, otherwise we might do wrong builddir
|
||||
B.root_build_dir = env['BF_BUILDDIR']
|
||||
|
@ -441,6 +441,15 @@ macro(TEST_SSE_SUPPORT
|
||||
unset(CMAKE_REQUIRED_FLAGS)
|
||||
endmacro()
|
||||
|
||||
macro(TEST_STDBOOL_SUPPORT)
|
||||
# This program will compile correctly if and only if
|
||||
# this C compiler supports C99 stdbool.
|
||||
check_c_source_runs("
|
||||
#include <stdbool.h>
|
||||
int main(void) { return (int)false; }"
|
||||
HAVE_STDBOOL_H)
|
||||
endmacro()
|
||||
|
||||
# when we have warnings as errors applied globally this
|
||||
# needs to be removed for some external libs which we dont maintain.
|
||||
|
||||
|
@ -32,12 +32,34 @@
|
||||
* \ingroup bli
|
||||
*/
|
||||
|
||||
#ifndef FALSE
|
||||
# define FALSE 0
|
||||
/* note: use of (int, TRUE / FALSE) is deprecated,
|
||||
* use (bool, true / false) instead */
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
# include <stdbool.h>
|
||||
#else
|
||||
# ifndef HAVE__BOOL
|
||||
# ifdef __cplusplus
|
||||
typedef bool _Bool;
|
||||
# else
|
||||
# define _Bool signed char
|
||||
# endif
|
||||
# endif
|
||||
# define bool _Bool
|
||||
# define false 0
|
||||
# define true 1
|
||||
# define __bool_true_false_are_defined 1
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
# define TRUE 1
|
||||
/* remove this when we're ready to remove TRUE/FALSE completely */
|
||||
#ifdef WITH_BOOL_COMPAT
|
||||
/* interim until all occurrences of these can be updated to stdbool */
|
||||
# ifndef FALSE
|
||||
# define FALSE 0
|
||||
# endif
|
||||
|
||||
# ifndef TRUE
|
||||
# define TRUE 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* useful for finding bad use of min/max */
|
||||
|
Loading…
Reference in New Issue
Block a user