1 /* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
20 * ISO C 9X: 7.5 Format conversion of integer types <inttypes.h>
27 /* Get the type definitions. */
31 /* The ISO C 9X standard specifies that these macros must only be
32 defined if explicitly requested. */
33 #if !defined __cplusplus || defined __STDC_FORMAT_MACROS
35 /* Macros for printing format specifiers. */
37 /* Decimal notation. */
43 # define PRIdLEAST8 "d"
44 # define PRIdLEAST16 "d"
45 # define PRIdLEAST32 "d"
46 # define PRIdLEAST64 "lld"
48 # define PRIdFAST8 "d"
49 # define PRIdFAST16 "d"
50 # define PRIdFAST32 "d"
51 # define PRIdFAST64 "lld"
59 # define PRIiLEAST8 "i"
60 # define PRIiLEAST16 "i"
61 # define PRIiLEAST32 "i"
62 # define PRIiLEAST64 "lli"
64 # define PRIiFAST8 "i"
65 # define PRIiFAST16 "i"
66 # define PRIiFAST32 "i"
67 # define PRIiFAST64 "lli"
75 # define PRIoLEAST8 "o"
76 # define PRIoLEAST16 "o"
77 # define PRIoLEAST32 "o"
78 # define PRIoLEAST64 "llo"
80 # define PRIoFAST8 "o"
81 # define PRIoFAST16 "o"
82 # define PRIoFAST32 "o"
83 # define PRIoFAST64 "llo"
85 /* Unsigned integers. */
91 # define PRIuLEAST8 "u"
92 # define PRIuLEAST16 "u"
93 # define PRIuLEAST32 "u"
94 # define PRIuLEAST64 "llu"
96 # define PRIuFAST8 "u"
97 # define PRIuFAST16 "u"
98 # define PRIuFAST32 "u"
99 # define PRIuFAST64 "llu"
101 /* lowercase hexadecimal notation. */
105 # define PRIx64 "llx"
107 # define PRIxLEAST8 "x"
108 # define PRIxLEAST16 "x"
109 # define PRIxLEAST32 "x"
110 # define PRIxLEAST64 "llx"
112 # define PRIxFAST8 "x"
113 # define PRIxFAST16 "x"
114 # define PRIxFAST32 "x"
115 # define PRIxFAST64 "llx"
117 /* UPPERCASE hexadecimal notation. */
121 # define PRIX64 "llX"
123 # define PRIXLEAST8 "X"
124 # define PRIXLEAST16 "X"
125 # define PRIXLEAST32 "X"
126 # define PRIXLEAST64 "llX"
128 # define PRIXFAST8 "X"
129 # define PRIXFAST16 "X"
130 # define PRIXFAST32 "X"
131 # define PRIXFAST64 "llX"
134 /* Macros for printing `intmax_t' and `uintmax_t'. */
135 # define PRIdMAX "lld"
136 # define PRIiMAX "lli"
137 # define PRIoMAX "llo"
138 # define PRIuMAX "llu"
139 # define PRIxMAX "llx"
140 # define PRIXMAX "llX"
143 /* Macros for printing `intptr_t' and `uintptr_t'. */
152 /* Macros for scanning format specifiers. */
154 /* Signed decimal notation. */
158 # define SCNd64 "lld"
160 # define SCNdLEAST8 "hhd"
161 # define SCNdLEAST16 "hd"
162 # define SCNdLEAST32 "d"
163 # define SCNdLEAST64 "lld"
165 # define SCNdFAST8 "hhd"
166 # define SCNdFAST16 "d"
167 # define SCNdFAST32 "d"
168 # define SCNdFAST64 "lld"
170 /* Signed decimal notation. */
174 # define SCNi64 "lli"
176 # define SCNiLEAST8 "hhi"
177 # define SCNiLEAST16 "hi"
178 # define SCNiLEAST32 "i"
179 # define SCNiLEAST64 "lli"
181 # define SCNiFAST8 "hhi"
182 # define SCNiFAST16 "i"
183 # define SCNiFAST32 "i"
184 # define SCNiFAST64 "lli"
186 /* Unsigned decimal notation. */
190 # define SCNu64 "llu"
192 # define SCNuLEAST8 "hhu"
193 # define SCNuLEAST16 "hu"
194 # define SCNuLEAST32 "u"
195 # define SCNuLEAST64 "llu"
197 # define SCNuFAST8 "hhu"
198 # define SCNuFAST16 "u"
199 # define SCNuFAST32 "u"
200 # define SCNuFAST64 "llu"
202 /* Octal notation. */
206 # define SCNo64 "llo"
208 # define SCNoLEAST8 "hho"
209 # define SCNoLEAST16 "ho"
210 # define SCNoLEAST32 "o"
211 # define SCNoLEAST64 "llo"
213 # define SCNoFAST8 "hho"
214 # define SCNoFAST16 "o"
215 # define SCNoFAST32 "o"
216 # define SCNoFAST64 "llo"
218 /* Hexadecimal notation. */
222 # define SCNx64 "llx"
224 # define SCNxLEAST8 "hhx"
225 # define SCNxLEAST16 "hx"
226 # define SCNxLEAST32 "x"
227 # define SCNxLEAST64 "llx"
229 # define SCNxFAST8 "hhx"
230 # define SCNxFAST16 "x"
231 # define SCNxFAST32 "x"
232 # define SCNxFAST64 "llx"
235 /* Macros for scanning `intmax_t' and `uintmax_t'. */
236 # define SCNdMAX "lld"
237 # define SCNiMAX "lli"
238 # define SCNoMAX "llo"
239 # define SCNuMAX "llu"
240 # define SCNxMAX "llx"
242 /* Macros for scaning `intptr_t' and `uintptr_t'. */
249 #endif /* C++ && format macros */
254 /* Like `strtol' but convert to `intmax_t'. */
255 extern intmax_t strtoimax
__P ((__const
char *__restrict __nptr
,
256 char **__restrict __endptr
, int __base
));
258 /* Like `strtoul' but convert to `uintmax_t'. */
259 extern uintmax_t strtoumax
__P ((__const
char * __restrict __nptr
,
260 char ** __restrict __endptr
, int __base
));
262 /* Like `wcstol' but convert to `intmax_t'. */
263 extern intmax_t wcstoimax
__P ((__const
wchar_t * __restrict __nptr
,
264 wchar_t **__restrict __endptr
, int __base
));
266 /* Like `wcstoul' but convert to `uintmax_t'. */
267 extern uintmax_t wcstoumax
__P ((__const
wchar_t * __restrict __nptr
,
268 wchar_t ** __restrict __endptr
, int __base
));
270 #ifdef __USE_EXTERN_INLINES
272 /* Like `strtol' but convert to `intmax_t'. */
273 # ifndef __strtoll_internal_defined
275 extern long long int __strtoll_internal
__P ((__const
char *__restrict __nptr
,
276 char **__restrict __endptr
,
277 int __base
, int __group
));
278 # define __strtoll_internal_defined 1
280 extern __inline
intmax_t
281 strtoimax (__const
char *__restrict nptr
, char **__restrict endptr
,
284 return __strtoll_internal (nptr
, endptr
, base
, 0);
287 /* Like `strtoul' but convert to `uintmax_t'. */
288 # ifndef __strtoull_internal_defined
290 extern unsigned long long int __strtoull_internal
__P ((__const
char *
296 # define __strtoull_internal_defined 1
298 extern __inline
uintmax_t
299 strtoumax (__const
char *__restrict nptr
, char **__restrict endptr
,
302 return __strtoull_internal (nptr
, endptr
, base
, 0);
305 /* Like `wcstol' but convert to `intmax_t'. */
306 # ifndef __wcstoll_internal_defined
308 extern long long int __wcstoll_internal
__P ((__const
wchar_t *
310 wchar_t **__restrict __endptr
,
311 int __base
, int __group
));
312 # define __wcstoll_internal_defined 1
314 extern __inline
intmax_t
315 wcstoimax (__const
wchar_t *__restrict nptr
, wchar_t **__restrict endptr
,
318 return __wcstoll_internal (nptr
, endptr
, base
, 0);
322 /* Like `wcstoul' but convert to `uintmax_t'. */
323 # ifndef __wcstoull_internal_defined
325 extern unsigned long long int __wcstoull_internal
__P ((__const
wchar_t *
331 # define __wcstoull_internal_defined 1
333 extern __inline
uintmax_t
334 wcstoumax (__const
wchar_t *__restrict nptr
, wchar_t **__restrict endptr
,
337 return __wcstoull_internal (nptr
, endptr
, base
, 0);
339 #endif /* Use extern inlines. */
343 #endif /* inttypes.h */