]> git.saurik.com Git - wxWidgets.git/commitdiff
define true/false if the compiler doesn't have them
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 7 Jan 2003 22:29:59 +0000 (22:29 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 7 Jan 2003 22:29:59 +0000 (22:29 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18630 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
include/wx/defs.h

index 0b3521290deb9e1ec7c0747346b9fd2b60f8612c..f010b4412cc43faccd5bde80c64d4e67f8c760b2 100644 (file)
@@ -19,6 +19,7 @@ All:
 - Implemented alignment for wxGrid bool editor and renderer
 - Support wxListCtrl columns alignment for all platforms and not just MSW
 - Added wxDateSpan::operator==() and !=() (Lukasz Michalski)
+- use true/false throughout the library instead of TRUE/FALSE
 
 Unix:
 
index 7216f53f05a4a9ae97121a6444df593d48155618..4d6f2106b538d77891680dfda4a8a82ea9b257fc 100644 (file)
     typedef unsigned int bool;
 #endif // bool
 
-#ifdef __cplusplus
-    // define boolean constants: don't use true/false here as not all compilers
-    // support them but also redefine TRUE which could have been defined as 1
-    // by previous headers: this would be incorrect as our TRUE is supposed to
-    // be of type bool, just like true, not int
-    //
-    // however if the user code absolutely needs TRUE to be defined in its own
-    // way, it can predefine WX_TRUE_DEFINED to prevent the redefinition here
-    #ifdef TRUE
-        #ifndef WX_TRUE_DEFINED
-            #undef TRUE
-            #undef FALSE
-        #endif
-    #endif
+// deal with TRUE/true stuff: we assume that if the compiler supports bool, it
+// supports true/false as well and that, OTOH, if it does _not_ support bool,
+// it doesn't support these keywords (this is less sure, in particular VC++
+// 4.x could be a problem here)
+#ifndef HAVE_BOOL
+    #define true ((bool)1)
+    #define false ((bool)0)
+#endif
 
-    #ifndef TRUE
-        #define TRUE  ((bool)1)
-        #define FALSE ((bool)0)
-    #endif
-#else // !__cplusplus
-    // the definitions above don't work for C sources
-    #ifndef TRUE
-        #define TRUE 1
-    #endif
+// for backwards compatibility, also define TRUE and FALSE
+//
+// note that these definitions should work both in C++ and C code, so don't
+// use true/false below
+#ifndef TRUE
+    #define TRUE 1
+#endif
 
-    #ifndef FALSE
-        #define FALSE 0
-    #endif
-#endif // C++/!C++
+#ifndef FALSE
+    #define FALSE 0
+#endif
 
 typedef short int WXTYPE;