changeset 10974:1aa0d3273940

Include <wchar.h> after defining the types, not before.
author Bruno Haible <bruno@clisp.org>
date Fri, 26 Dec 2008 11:00:05 +0100
parents e1a3422c4e90
children b7338e6c661f
files ChangeLog lib/stdint.in.h
diffstat 2 files changed, 14 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-12-26  Bruno Haible  <bruno@clisp.org>
+
+	* lib/stdint.in.h: Move the include of <wchar.h> down until after all
+	the types are defined. Also conditionalize it on __STDC_LIMIT_MACROS,
+	not __STDC_CONSTANT_MACROS.
+	Reported by Nelson H. F. Beebe <beebe@math.utah.edu> via Eric Blake.
+
 2008-12-25  Bruno Haible  <bruno@clisp.org>
 
 	Add support for universal builds to vasnprintf.
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -89,15 +89,6 @@
 # include <sys/bitypes.h>
 #endif
 
-#if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS
-
-/* Get WCHAR_MIN, WCHAR_MAX.  */
-# if ! (defined WCHAR_MIN && defined WCHAR_MAX)
-#  include <wchar.h>
-# endif
-
-#endif
-
 #undef _GL_JUST_INCLUDE_SYSTEM_INTTYPES_H
 
 /* Minimum and maximum values for a integer type under the usual assumption.
@@ -482,6 +473,13 @@
 #endif
 
 /* wchar_t limits */
+/* Get WCHAR_MIN, WCHAR_MAX.
+   This include is not on the top, above, because on OSF/1 4.0 we have a sequence of nested
+   includes <wchar.h> -> <stdio.h> -> <getopt.h> -> <stdlib.h>, and the latter includes
+   <stdint.h> and assumes its types are already defined.  */
+#if ! (defined WCHAR_MIN && defined WCHAR_MAX)
+# include <wchar.h>
+#endif
 #undef WCHAR_MIN
 #undef WCHAR_MAX
 #define WCHAR_MIN  \