]> granicus.if.org Git - clang/commitdiff
Implement a __WCHAR_UNSIGNED__ macro and use it to include WCHAR_MIN and
authorSean Hunt <scshunt@csclub.uwaterloo.ca>
Tue, 19 Jul 2011 00:50:57 +0000 (00:50 +0000)
committerSean Hunt <scshunt@csclub.uwaterloo.ca>
Tue, 19 Jul 2011 00:50:57 +0000 (00:50 +0000)
WCHAR_MAX in limits.h, thus solving the problem where the system header
thinks it knows better.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135455 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/InitPreprocessor.cpp
lib/Headers/limits.h

index 9428cd5de0f348df5a2f6449088ec8d06157175d..77a1b3f396ac2cfb4e1e5648b9502a8cad201774 100644 (file)
@@ -554,6 +554,9 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
   if (!TargetInfo::isTypeSigned(TI.getWIntType()))
     Builder.defineMacro("__WINT_UNSIGNED__");
 
+  if (!TargetInfo::isTypeSigned(TI.getWCharType()))
+    Builder.defineMacro("__WCHAR_UNSIGNED__");
+
   // Define exact-width integer types for stdint.h
   Builder.defineMacro("__INT" + llvm::Twine(TI.getCharWidth()) + "_TYPE__",
                       "char");
index ecd09a4a246d331be58e8d7343753f26853b6ecb..6683a2db727272b1bb7d4dc59aa6415c530ca8f1 100644 (file)
@@ -52,6 +52,8 @@
 #undef  LONG_MIN
 #undef  LONG_MAX
 #undef  ULONG_MAX
+#undef  WCHAR_MIN
+#undef  WCHAR_MAX
 
 #undef  CHAR_BIT
 #undef  CHAR_MIN
@@ -62,6 +64,7 @@
 #define SHRT_MAX  __SHRT_MAX__
 #define INT_MAX   __INT_MAX__
 #define LONG_MAX  __LONG_MAX__
+#define WCHAR_MAX __WCHAR_MAX__
 
 #define SCHAR_MIN (-__SCHAR_MAX__-1)
 #define SHRT_MIN  (-__SHRT_MAX__ -1)
 #define CHAR_MAX __SCHAR_MAX__
 #endif
 
+/* C++ or C99: Added wchar_t */
+#if defined(__cplusplus) || __STDC_VERSION__ >= 199901
+
+#ifdef __WCHAR_UNSIGNED__
+#define WCHAR_MIN 0
+#else
+#define WCHAR_MIN (-__WCHAR_MAX__-1)
+#endif
+
+#endif
+
 /* C99 5.2.4.2.1: Added long long. */
 #if __STDC_VERSION__ >= 199901