[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [53480] trunk/blender: patch [#33331] Time To Start Moving To Stdbool
Campbell Barton
ideasman42 at gmail.com
Tue Jan 1 13:48:02 CET 2013
Revision: 53480
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=53480
Author: campbellbarton
Date: 2013-01-01 12:47:58 +0000 (Tue, 01 Jan 2013)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/CMakeLists.txt
trunk/blender/SConstruct
trunk/blender/build_files/cmake/macros.cmake
trunk/blender/source/blender/blenlib/BLI_utildefines.h
Modified: trunk/blender/CMakeLists.txt
===================================================================
--- trunk/blender/CMakeLists.txt 2013-01-01 11:47:47 UTC (rev 53479)
+++ trunk/blender/CMakeLists.txt 2013-01-01 12:47:58 UTC (rev 53480)
@@ -149,7 +149,10 @@
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))
set(PLATFORM_DEFAULT ON)
@@ -264,7 +267,6 @@
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 @@
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 @@
message("${_config_msg}")
endif()
+
+# debug
+message(
+ STATUS "HAVE_STDBOOL_H = ${HAVE_STDBOOL_H}"
+)
Modified: trunk/blender/SConstruct
===================================================================
--- trunk/blender/SConstruct 2013-01-01 11:47:47 UTC (rev 53479)
+++ trunk/blender/SConstruct 2013-01-01 12:47:58 UTC (rev 53480)
@@ -373,9 +373,10 @@
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']
Modified: trunk/blender/build_files/cmake/macros.cmake
===================================================================
--- trunk/blender/build_files/cmake/macros.cmake 2013-01-01 11:47:47 UTC (rev 53479)
+++ trunk/blender/build_files/cmake/macros.cmake 2013-01-01 12:47:58 UTC (rev 53480)
@@ -441,6 +441,15 @@
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.
Modified: trunk/blender/source/blender/blenlib/BLI_utildefines.h
===================================================================
--- trunk/blender/source/blender/blenlib/BLI_utildefines.h 2013-01-01 11:47:47 UTC (rev 53479)
+++ trunk/blender/source/blender/blenlib/BLI_utildefines.h 2013-01-01 12:47:58 UTC (rev 53480)
@@ -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 */
More information about the Bf-blender-cvs
mailing list