]>
git.saurik.com Git - apple/libc.git/blob - include/inttypes.h
2 * Copyright (c) 2000, 2001, 2002, 2003, 2004 Apple Computer, Inc.
5 * @APPLE_LICENSE_HEADER_START@
7 * The contents of this file constitute Original Code as defined in and
8 * are subject to the Apple Public Source License Version 1.1 (the
9 * "License"). You may not use this file except in compliance with the
10 * License. Please obtain a copy of the License at
11 * http://www.apple.com/publicsource and read it before using this file.
13 * This Original Code and all software distributed under the License are
14 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
18 * License for the specific language governing rights and limitations
21 * @APPLE_LICENSE_HEADER_END@
25 * <inttypes.h> -- Standard C header, defined in ISO/IEC 9899:1999
26 * (aka "C99"), section 7.8. This defines format string conversion
27 * specifiers suitable for use within arguments to fprintf and fscanf
31 #if !defined(_INTTYPES_H_)
34 #include <sys/cdefs.h> /* For __BEGIN_DECLS and __END_DECLS */
35 #include <_types.h> /* For __darwin_wchar_t */
38 #if !defined(__STDC_VERSION__) || (__STDC_VERSION__ < 199901L)
39 /* Translator is not ISO/IEC 9899:1999-compliant. */
40 # if !defined(restrict)
42 # define __RESTRICT_KEYWORD_DEFINED__
46 /* "C++ implementations should define these macros only when
47 * __STDC_FORMAT_MACROS is defined before <inttypes.h> is included."
49 #if (! defined(__cplusplus)) || defined(__STDC_FORMAT_MACROS)
51 # undef __PRI_8_LENGTH_MODIFIER__
52 # undef __PRI_64_LENGTH_MODIFIER__
53 # undef __SCN_64_LENGTH_MODIFIER__
55 /* These could be "hh", "ll", and "ll" respectively, but that doesn't work on
56 10.2, and these do. Note that there's no way to use scanf to scan a
57 decimal into a 'char' argument on 10.2, so "hh" is used unconditionally
58 and programs that use it won't work on Jaguar. */
59 # define __PRI_8_LENGTH_MODIFIER__ "" /* none */
60 # define __PRI_64_LENGTH_MODIFIER__ "q"
61 # define __SCN_64_LENGTH_MODIFIER__ "q"
62 # define __PRI_MAX_LENGTH_MODIFIER__ "j"
63 # define __SCN_MAX_LENGTH_MODIFIER__ "j"
65 # define PRId8 __PRI_8_LENGTH_MODIFIER__ "d"
66 # define PRIi8 __PRI_8_LENGTH_MODIFIER__ "i"
67 # define PRIo8 __PRI_8_LENGTH_MODIFIER__ "o"
68 # define PRIu8 __PRI_8_LENGTH_MODIFIER__ "u"
69 # define PRIx8 __PRI_8_LENGTH_MODIFIER__ "x"
70 # define PRIX8 __PRI_8_LENGTH_MODIFIER__ "X"
86 # define PRId64 __PRI_64_LENGTH_MODIFIER__ "d"
87 # define PRIi64 __PRI_64_LENGTH_MODIFIER__ "i"
88 # define PRIo64 __PRI_64_LENGTH_MODIFIER__ "o"
89 # define PRIu64 __PRI_64_LENGTH_MODIFIER__ "u"
90 # define PRIx64 __PRI_64_LENGTH_MODIFIER__ "x"
91 # define PRIX64 __PRI_64_LENGTH_MODIFIER__ "X"
93 # define PRIdLEAST8 PRId8
94 # define PRIiLEAST8 PRIi8
95 # define PRIoLEAST8 PRIo8
96 # define PRIuLEAST8 PRIu8
97 # define PRIxLEAST8 PRIx8
98 # define PRIXLEAST8 PRIX8
100 # define PRIdLEAST16 PRId16
101 # define PRIiLEAST16 PRIi16
102 # define PRIoLEAST16 PRIo16
103 # define PRIuLEAST16 PRIu16
104 # define PRIxLEAST16 PRIx16
105 # define PRIXLEAST16 PRIX16
107 # define PRIdLEAST32 PRId32
108 # define PRIiLEAST32 PRIi32
109 # define PRIoLEAST32 PRIo32
110 # define PRIuLEAST32 PRIu32
111 # define PRIxLEAST32 PRIx32
112 # define PRIXLEAST32 PRIX32
114 # define PRIdLEAST64 PRId64
115 # define PRIiLEAST64 PRIi64
116 # define PRIoLEAST64 PRIo64
117 # define PRIuLEAST64 PRIu64
118 # define PRIxLEAST64 PRIx64
119 # define PRIXLEAST64 PRIX64
121 # define PRIdFAST8 PRId8
122 # define PRIiFAST8 PRIi8
123 # define PRIoFAST8 PRIo8
124 # define PRIuFAST8 PRIu8
125 # define PRIxFAST8 PRIx8
126 # define PRIXFAST8 PRIX8
128 # define PRIdFAST16 PRId16
129 # define PRIiFAST16 PRIi16
130 # define PRIoFAST16 PRIo16
131 # define PRIuFAST16 PRIu16
132 # define PRIxFAST16 PRIx16
133 # define PRIXFAST16 PRIX16
135 # define PRIdFAST32 PRId32
136 # define PRIiFAST32 PRIi32
137 # define PRIoFAST32 PRIo32
138 # define PRIuFAST32 PRIu32
139 # define PRIxFAST32 PRIx32
140 # define PRIXFAST32 PRIX32
142 # define PRIdFAST64 PRId64
143 # define PRIiFAST64 PRIi64
144 # define PRIoFAST64 PRIo64
145 # define PRIuFAST64 PRIu64
146 # define PRIxFAST64 PRIx64
147 # define PRIXFAST64 PRIX64
149 /* int32_t is 'int', but intptr_t is 'long'. */
150 # define PRIdPTR "ld"
151 # define PRIiPTR "li"
152 # define PRIoPTR "lo"
153 # define PRIuPTR "lu"
154 # define PRIxPTR "lx"
155 # define PRIXPTR "lX"
157 # define PRIdMAX __PRI_MAX_LENGTH_MODIFIER__ "d"
158 # define PRIiMAX __PRI_MAX_LENGTH_MODIFIER__ "i"
159 # define PRIoMAX __PRI_MAX_LENGTH_MODIFIER__ "o"
160 # define PRIuMAX __PRI_MAX_LENGTH_MODIFIER__ "u"
161 # define PRIxMAX __PRI_MAX_LENGTH_MODIFIER__ "x"
162 # define PRIXMAX __PRI_MAX_LENGTH_MODIFIER__ "X"
182 # define SCNd64 __SCN_64_LENGTH_MODIFIER__ "d"
183 # define SCNi64 __SCN_64_LENGTH_MODIFIER__ "i"
184 # define SCNo64 __SCN_64_LENGTH_MODIFIER__ "o"
185 # define SCNu64 __SCN_64_LENGTH_MODIFIER__ "u"
186 # define SCNx64 __SCN_64_LENGTH_MODIFIER__ "x"
188 # define SCNdLEAST8 SCNd8
189 # define SCNiLEAST8 SCNi8
190 # define SCNoLEAST8 SCNo8
191 # define SCNuLEAST8 SCNu8
192 # define SCNxLEAST8 SCNx8
194 # define SCNdLEAST16 SCNd16
195 # define SCNiLEAST16 SCNi16
196 # define SCNoLEAST16 SCNo16
197 # define SCNuLEAST16 SCNu16
198 # define SCNxLEAST16 SCNx16
200 # define SCNdLEAST32 SCNd32
201 # define SCNiLEAST32 SCNi32
202 # define SCNoLEAST32 SCNo32
203 # define SCNuLEAST32 SCNu32
204 # define SCNxLEAST32 SCNx32
206 # define SCNdLEAST64 SCNd64
207 # define SCNiLEAST64 SCNi64
208 # define SCNoLEAST64 SCNo64
209 # define SCNuLEAST64 SCNu64
210 # define SCNxLEAST64 SCNx64
212 # define SCNdFAST8 SCNd8
213 # define SCNiFAST8 SCNi8
214 # define SCNoFAST8 SCNo8
215 # define SCNuFAST8 SCNu8
216 # define SCNxFAST8 SCNx8
218 # define SCNdFAST16 SCNd16
219 # define SCNiFAST16 SCNi16
220 # define SCNoFAST16 SCNo16
221 # define SCNuFAST16 SCNu16
222 # define SCNxFAST16 SCNx16
224 # define SCNdFAST32 SCNd32
225 # define SCNiFAST32 SCNi32
226 # define SCNoFAST32 SCNo32
227 # define SCNuFAST32 SCNu32
228 # define SCNxFAST32 SCNx32
230 # define SCNdFAST64 SCNd64
231 # define SCNiFAST64 SCNi64
232 # define SCNoFAST64 SCNo64
233 # define SCNuFAST64 SCNu64
234 # define SCNxFAST64 SCNx64
236 # define SCNdPTR "ld"
237 # define SCNiPTR "li"
238 # define SCNoPTR "lo"
239 # define SCNuPTR "lu"
240 # define SCNxPTR "lx"
242 # define SCNdMAX __SCN_MAX_LENGTH_MODIFIER__ "d"
243 # define SCNiMAX __SCN_MAX_LENGTH_MODIFIER__ "i"
244 # define SCNoMAX __SCN_MAX_LENGTH_MODIFIER__ "o"
245 # define SCNuMAX __SCN_MAX_LENGTH_MODIFIER__ "u"
246 # define SCNxMAX __SCN_MAX_LENGTH_MODIFIER__ "x"
248 #endif /* if C++, then __STDC_FORMAT_MACROS enables the above macros */
253 extern intmax_t imaxabs(intmax_t j
);
261 extern imaxdiv_t
imaxdiv(intmax_t numer
, intmax_t denom
);
264 extern intmax_t strtoimax(const char * restrict nptr
, char ** restrict endptr
, int base
);
265 extern uintmax_t strtoumax(const char * restrict nptr
, char ** restrict endptr
, int base
);
267 #ifndef __cplusplus /* wchar_t is a built-in type in C++ */
270 typedef __darwin_wchar_t
wchar_t;
271 # endif /* _WCHAR_T */
272 #endif /* __cplusplus */
275 extern intmax_t wcstoimax(const wchar_t * restrict nptr
, wchar_t ** restrict endptr
, int base
);
276 extern uintmax_t wcstoumax(const wchar_t * restrict nptr
, wchar_t ** restrict endptr
, int base
);
280 #ifdef _USE_EXTENDED_LOCALES_
281 #include <xlocale/_inttypes.h>
282 #endif /* _USE_EXTENDED_LOCALES_ */
285 No need to #undef the __*_{8,64}_LENGTH_MODIFIER__ macros;
286 in fact, you can't #undef them, because later uses of any of
287 their dependents will *not* then do the intended substitution.
288 Expansion of a #define like this one:
292 uses the cpp value of IDENT at the location where x is *expanded*,
293 not where it is #defined.
296 #if defined(__RESTRICT_KEYWORD_DEFINED__)
298 # undef __RESTRICT_KEYWORD_DEFINED__
301 #endif /* !_INTTYPES_H_ */