summaryrefslogtreecommitdiff
path: root/ndk/platforms/android-8/include/wchar.h
diff options
context:
space:
mode:
Diffstat (limited to 'ndk/platforms/android-8/include/wchar.h')
-rw-r--r--ndk/platforms/android-8/include/wchar.h36
1 files changed, 34 insertions, 2 deletions
diff --git a/ndk/platforms/android-8/include/wchar.h b/ndk/platforms/android-8/include/wchar.h
index b9c7b0b48..e67b0be73 100644
--- a/ndk/platforms/android-8/include/wchar.h
+++ b/ndk/platforms/android-8/include/wchar.h
@@ -70,9 +70,41 @@ typedef enum {
WC_TYPE_MAX
} wctype_t;
-#define WCHAR_MAX 255
-#define WCHAR_MIN 0
+/* TECHNICAL NOTE: This is tricky!
+ *
+ * Due to the following inclusion chain:
+ * <wchar.h> -> <stdio.h> -> <sys/types.h> -> <stdint.h>
+ *
+ * WCHAR_MIN / WCHAR_MAX will already be defined to INT32_MIN / INT32_MAX
+ * when reaching this line in the following cases:
+ * - Compiling C source code.
+ * - Compiling C++ source code AND having __STDC_LIMIT_MACROS defined.
+ *
+ * When _WCHAR_IS_8BIT is defined, it should emulate the old behaviour.
+ * which was to set the values to 0 and 255, respectively.
+ */
+#ifndef WCHAR_MAX
+# ifdef _WCHAR_IS_8BIT
+# define WCHAR_MAX 255
+# define WCHAR_MIN 0
+# else
+/* Same values as INT32_MIN/INT32_MAX, without including <stdint.h> */
+# define WCHAR_MAX (2147483647)
+# define WCHAR_MIN (-1-2147483647)
+# endif
+#endif
+
+/* Similarly, WEOF used to be defined as simply -1, which is
+ * invalid (the standard mandates that the expression must have wint_t
+ * type). There is no difference in C, but there is one in C++!!
+ *
+ * Revert to the old broken behaviour is _WCHAR_IS_8BIT is defined.
+ */
+#ifdef _WCHAR_IS_8BIT
#define WEOF (-1)
+#else
+#define WEOF ((wint_t)-1)
+#endif
extern wint_t btowc(int);
extern int fwprintf(FILE *, const wchar_t *, ...);