summaryrefslogtreecommitdiff
path: root/lib/stdint.in.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-12-13 15:27:41 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2011-12-13 15:30:25 -0800
commit443bc5ffcf7429e557f4a371b0661abe98ddbc13 (patch)
tree910db7e19dbd3b9177f0fe709628a5f20d355601 /lib/stdint.in.h
parent91cc546b14935ac246f177ea62f945b86d9c4760 (diff)
downloadgnulib-443bc5ffcf7429e557f4a371b0661abe98ddbc13.tar.gz
inttypes, stdint: add C++11 support
C++11 says there's no need to define __STDC_CONSTANT_MACROS etc. when including inttypes.h and stdint.h. Support this change to the standard. * doc/posix-headers/inttypes.texi (inttypes.h): * doc/posix-headers/stdint.texi (stdint.h): Document this. * lib/inttypes.in.h (__STDC_FORMAT_MACROS) [! __cplusplus]: Define if not defined already, for the benefit of pre-C++11 hosts. Define the standard format macros (e.g., PRId8) always. * lib/stdint.in.h (__STDC_CONSTANT_MACROS, __STDC_LIMIT_MACROS): Likewise, if __cpluspus. Define the standard constant and limit macros (e.g., INT8_C, INT8_MAX) always. * m4/inttypes.m4 (gl_INTTYPES_INCOMPLETE): Do not define GL_TRIGGER_STDC_LIMIT_MACROS or __STDC_LIMIT_MACROS; no longer needed. * m4/stdint.m4 (gl_STDINT_H): Update comments about these macros. * tests/test-inttypes.c (__STDC_LIMIT_MACROS, __STDC_CONSTANT_MACROS) (__STDC_FORMAT_MACROS): Do not define, since we assume C++11 API now. * tests/test-stdint.c (__STDC_LIMIT_MACROS, __STDC_CONSTANT_MACROS): Likewise.
Diffstat (limited to 'lib/stdint.in.h')
-rw-r--r--lib/stdint.in.h19
1 files changed, 11 insertions, 8 deletions
diff --git a/lib/stdint.in.h b/lib/stdint.in.h
index aa5ca911e3..7769582683 100644
--- a/lib/stdint.in.h
+++ b/lib/stdint.in.h
@@ -49,6 +49,17 @@
diagnostics. */
# define __STDINT_H__
# endif
+
+ /* Some pre-C++11 <stdint.h> implementations need this. */
+# ifdef __cplusplus
+# ifndef __STDC_CONSTANT_MACROS
+# define __STDC_CONSTANT_MACROS 1
+# endif
+# ifndef __STDC_LIMIT_MACROS
+# define __STDC_LIMIT_MACROS 1
+# endif
+# endif
+
/* Other systems may have an incomplete or buggy <stdint.h>.
Include it before <inttypes.h>, since any "#include <stdint.h>"
in <inttypes.h> would reinclude us, skipping our contents because
@@ -313,8 +324,6 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
/* 7.18.2. Limits of specified-width integer types */
-#if ! defined __cplusplus || defined __STDC_LIMIT_MACROS
-
/* 7.18.2.1. Limits of exact-width integer types */
/* Here we assume a standard architecture where the hardware integer
@@ -534,12 +543,8 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
#define WINT_MAX \
_STDINT_MAX (@HAVE_SIGNED_WINT_T@, @BITSIZEOF_WINT_T@, 0@WINT_T_SUFFIX@)
-#endif /* !defined __cplusplus || defined __STDC_LIMIT_MACROS */
-
/* 7.18.4. Macros for integer constants */
-#if ! defined __cplusplus || defined __STDC_CONSTANT_MACROS
-
/* 7.18.4.1. Macros for minimum-width integer constants */
/* According to ISO C 99 Technical Corrigendum 1 */
@@ -600,7 +605,5 @@ typedef int _verify_intmax_size[sizeof (intmax_t) == sizeof (uintmax_t)
# endif
#endif
-#endif /* !defined __cplusplus || defined __STDC_CONSTANT_MACROS */
-
#endif /* _@GUARD_PREFIX@_STDINT_H */
#endif /* !defined _@GUARD_PREFIX@_STDINT_H && !defined _GL_JUST_INCLUDE_SYSTEM_STDINT_H */