struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / device / include / inttypes.h
blobbd4dce1dd512baae38f2e1c26b17aa51b48c6501
1 /*-------------------------------------------------------------------------
2 inttypes.h - ISO C99 7.8 Format conversion of integer types <inttypes.h>
4 Copyright (C) 2019-2023, Benedikt Freisen, b.freisen@gmx.net
6 This library is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this library; see the file COPYING. If not, write to the
18 Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
19 MA 02110-1301, USA.
21 As a special exception, if you link this library with other files,
22 some of which are compiled with SDCC, to produce an executable,
23 this library does not by itself cause the resulting executable to
24 be covered by the GNU General Public License. This exception does
25 not however invalidate any other reasons why the executable file
26 might be covered by the GNU General Public License.
27 -------------------------------------------------------------------------*/
29 #ifndef _INTTYPES_H
30 #define _INTTYPES_H 1
32 /* the relevant integer types are defined in stdint.h */
34 #include <stdint.h>
36 /* conversion specifiers suitable for int8_t and uint8_t */
38 #define PRId8 "hhd"
39 #define PRIi8 "hhi"
40 #define PRIo8 "hho"
41 #define PRIu8 "hhu"
42 #define PRIx8 "hhx"
43 #define PRIX8 "hhX"
44 #define SCNd8 "hhd"
45 #define SCNi8 "hhi"
46 #define SCNo8 "hho"
47 #define SCNu8 "hhu"
48 #define SCNx8 "hhx"
50 /* conversion specifiers suitable for int_least8_t and uint_least8_t */
52 #define PRIdLEAST8 "hhd"
53 #define PRIiLEAST8 "hhi"
54 #define PRIoLEAST8 "hho"
55 #define PRIuLEAST8 "hhu"
56 #define PRIxLEAST8 "hhx"
57 #define PRIXLEAST8 "hhX"
58 #define SCNdLEAST8 "hhd"
59 #define SCNiLEAST8 "hhi"
60 #define SCNoLEAST8 "hho"
61 #define SCNuLEAST8 "hhu"
62 #define SCNxLEAST8 "hhx"
64 /* conversion specifiers suitable for int_fast8_t and uint_fast8_t */
66 #define PRIdFAST8 "hhd"
67 #define PRIiFAST8 "hhi"
68 #define PRIoFAST8 "hho"
69 #define PRIuFAST8 "hhu"
70 #define PRIxFAST8 "hhx"
71 #define PRIXFAST8 "hhX"
72 #define SCNdFAST8 "hhd"
73 #define SCNiFAST8 "hhi"
74 #define SCNoFAST8 "hho"
75 #define SCNuFAST8 "hhu"
76 #define SCNxFAST8 "hhx"
78 /* conversion specifiers suitable for int16_t and uint16_t */
80 #define PRId16 "hd"
81 #define PRIi16 "hi"
82 #define PRIo16 "ho"
83 #define PRIu16 "hu"
84 #define PRIx16 "hx"
85 #define PRIX16 "hX"
86 #define SCNd16 "hd"
87 #define SCNi16 "hi"
88 #define SCNo16 "ho"
89 #define SCNu16 "hu"
90 #define SCNx16 "hx"
92 /* conversion specifiers suitable for int_least_16_t and uint_least16_t */
94 #define PRIdLEAST16 "hd"
95 #define PRIiLEAST16 "hi"
96 #define PRIoLEAST16 "ho"
97 #define PRIuLEAST16 "hu"
98 #define PRIxLEAST16 "hx"
99 #define PRIXLEAST16 "hX"
100 #define SCNdLEAST16 "hd"
101 #define SCNiLEAST16 "hi"
102 #define SCNoLEAST16 "ho"
103 #define SCNuLEAST16 "hu"
104 #define SCNxLEAST16 "hx"
106 /* conversion specifiers suitable for int_fast16_t and uint_fast16_t */
108 #define PRIdFAST16 "hd"
109 #define PRIiFAST16 "hi"
110 #define PRIoFAST16 "ho"
111 #define PRIuFAST16 "hu"
112 #define PRIxFAST16 "hx"
113 #define PRIXFAST16 "hX"
114 #define SCNdFAST16 "hd"
115 #define SCNiFAST16 "hi"
116 #define SCNoFAST16 "ho"
117 #define SCNuFAST16 "hu"
118 #define SCNxFAST16 "hx"
120 /* conversion specifiers suitable for int32_t and uint32_t */
122 #define PRId32 "ld"
123 #define PRIi32 "li"
124 #define PRIo32 "lo"
125 #define PRIu32 "lu"
126 #define PRIx32 "lx"
127 #define PRIX32 "lX"
128 #define SCNd32 "ld"
129 #define SCNi32 "li"
130 #define SCNo32 "lo"
131 #define SCNu32 "lu"
132 #define SCNx32 "lx"
134 /* conversion specifiers suitable for int_least32_t and uint_least32_t */
136 #define PRIdLEAST32 "ld"
137 #define PRIiLEAST32 "li"
138 #define PRIoLEAST32 "lo"
139 #define PRIuLEAST32 "lu"
140 #define PRIxLEAST32 "lx"
141 #define PRIXLEAST32 "lX"
142 #define SCNdLEAST32 "ld"
143 #define SCNiLEAST32 "li"
144 #define SCNoLEAST32 "lo"
145 #define SCNuLEAST32 "lu"
146 #define SCNxLEAST32 "lx"
148 /* conversion specifiers suitable for int_fast32_t and uint_fast32_t */
150 #define PRIdFAST32 "ld"
151 #define PRIiFAST32 "li"
152 #define PRIoFAST32 "lo"
153 #define PRIuFAST32 "lu"
154 #define PRIxFAST32 "lx"
155 #define PRIXFAST32 "lX"
156 #define SCNdFAST32 "ld"
157 #define SCNiFAST32 "li"
158 #define SCNoFAST32 "lo"
159 #define SCNuFAST32 "lu"
160 #define SCNxFAST32 "lx"
162 /* conversion specifiers suitable for int64_t and uint64_t */
164 #define PRId64 "lld"
165 #define PRIi64 "lli"
166 #define PRIo64 "llo"
167 #define PRIu64 "llu"
168 #define PRIx64 "llx"
169 #define PRIX64 "llX"
170 #define SCNd64 "lld"
171 #define SCNi64 "lli"
172 #define SCNo64 "llo"
173 #define SCNu64 "llu"
174 #define SCNx64 "llx"
176 /* conversion specifiers suitable for int_least64_t and uint_least64_t */
178 #define PRIdLEAST64 "lld"
179 #define PRIiLEAST64 "lli"
180 #define PRIoLEAST64 "llo"
181 #define PRIuLEAST64 "llu"
182 #define PRIxLEAST64 "llx"
183 #define PRIXLEAST64 "llX"
184 #define SCNdLEAST64 "lld"
185 #define SCNiLEAST64 "lli"
186 #define SCNoLEAST64 "llo"
187 #define SCNuLEAST64 "llu"
188 #define SCNxLEAST64 "llx"
190 /* conversion specifiers suitable for int_fast64_t and uint_fast64_t */
192 #define PRIdFAST64 "lld"
193 #define PRIiFAST64 "lli"
194 #define PRIoFAST64 "llo"
195 #define PRIuFAST64 "llu"
196 #define PRIxFAST64 "llx"
197 #define PRIXFAST64 "llX"
198 #define SCNdFAST64 "lld"
199 #define SCNiFAST64 "lli"
200 #define SCNoFAST64 "llo"
201 #define SCNuFAST64 "llu"
202 #define SCNxFAST64 "llx"
204 /* conversion specifiers suitable for intmax_t and uintmax_t */
206 #define PRIdMAX "jd"
207 #define PRIiMAX "ji"
208 #define PRIoMAX "jo"
209 #define PRIuMAX "ju"
210 #define PRIxMAX "jx"
211 #define PRIXMAX "jX"
212 #define SCNdMAX "jd"
213 #define SCNiMAX "ji"
214 #define SCNoMAX "jo"
215 #define SCNuMAX "ju"
216 #define SCNxMAX "jx"
218 /* conversion specifiers suitable for intptr_t and uintptr_t */
220 #define PRIdPTR "td"
221 #define PRIiPTR "ti"
222 #define PRIoPTR "to"
223 #define PRIuPTR "tu"
224 #define PRIxPTR "tx"
225 #define PRIXPTR "tX"
226 #define SCNdPTR "td"
227 #define SCNiPTR "ti"
228 #define SCNoPTR "to"
229 #define SCNuPTR "tu"
230 #define SCNxPTR "tx"
232 /* result type of the imaxdiv function */
234 typedef struct {
235 intmax_t quot;
236 intmax_t rem;
237 } imaxdiv_t;
239 /* declarations of functions related to intmax_t and uintmax_t */
241 intmax_t imaxabs(intmax_t j);
243 /* NOTE: SDCC does not currently support struct return types on these architectures */
244 #if !defined(__SDCC_ds390) && !defined(__SDCC_hc08) && !defined(__SDCC_s08) && !defined(__SDCC_mos6502) && !defined(__SDCC_pic14) && !defined(__SDCC_pic16)
245 imaxdiv_t imaxdiv(intmax_t numer, intmax_t denom);
246 #endif
248 intmax_t strtoimax(const char * restrict nptr, char ** restrict endptr, int base);
249 uintmax_t strtoumax(const char * restrict nptr, char ** restrict endptr, int base);
251 #ifdef __WCHAR_T_DEFINED
252 intmax_t wcstoimax(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base);
253 uintmax_t wcstoumax(const wchar_t * restrict nptr, wchar_t ** restrict endptr, int base);
254 #endif
256 #endif /* inttypes.h */