AVR-LibC  2.3.0git
Standard C library for AVR-GCC
 

AVR-LibC Documen­tation

AVR-LibC Development Pages

Main Page

User Manual

Library Refe­rence

FAQ

Example Projects

File List

Index

Loading...
Searching...
No Matches
stdint.h
Go to the documentation of this file.
1/* Copyright (c) 2002,2004,2005 Marek Michalkiewicz
2 Copyright (c) 2005, Carlos Lamas
3 Copyright (c) 2005,2007 Joerg Wunsch
4 Copyright (c) 2013 Embecosm
5 All rights reserved.
6
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9
10 * Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
12
13 * Redistributions in binary form must reproduce the above copyright
14 notice, this list of conditions and the following disclaimer in
15 the documentation and/or other materials provided with the
16 distribution.
17
18 * Neither the name of the copyright holders nor the names of
19 contributors may be used to endorse or promote products derived
20 from this software without specific prior written permission.
21
22 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32 POSSIBILITY OF SUCH DAMAGE. */
33
34/*
35 * ISO/IEC 9899:1999 7.18 Integer types <stdint.h>
36 */
37
38#ifndef __STDINT_H_
39#define __STDINT_H_
40
41/** \file */
42/** \defgroup avr_stdint <stdint.h>: Standard Integer Types
43 \code #include <stdint.h> \endcode
44
45 Use [u]intN_t if you need exactly N bits.
46
47 Since these typedefs are mandated by the C99 standard, they are preferred
48 over rolling your own typedefs. */
49
50#ifndef __DOXYGEN__
51/*
52 * __USING_MINT8 is defined to 1 if the -mint8 option is in effect.
53 */
54#if __INT_MAX__ == 127
55# define __USING_MINT8 1
56#else
57# define __USING_MINT8 0
58#endif
59
60#endif /* !__DOXYGEN__ */
61
62/* Integer types */
63
64#if defined(__DOXYGEN__)
65
66/* doxygen gets confused by the __attribute__ stuff */
67
68/** \name Exact-width integer types
69 Integer types having exactly the specified width */
70
71/**@{*/
72
73/** \ingroup avr_stdint
74 8-bit signed type. */
75
76typedef signed char int8_t;
77
78/** \ingroup avr_stdint
79 8-bit unsigned type. */
80
81typedef unsigned char uint8_t;
82
83/** \ingroup avr_stdint
84 16-bit signed type. */
85
86typedef signed int int16_t;
87
88/** \ingroup avr_stdint
89 16-bit unsigned type. */
90
91typedef unsigned int uint16_t;
92
93/** \ingroup avr_stdint
94 32-bit signed type. */
95
96typedef signed long int int32_t;
97
98/** \ingroup avr_stdint
99 32-bit unsigned type. */
100
101typedef unsigned long int uint32_t;
102
103/** \ingroup avr_stdint
104 64-bit signed type.
105 \note This type is not available when the compiler
106 option \c -mint8 is in effect. */
107
108typedef signed long long int int64_t;
109
110/** \ingroup avr_stdint
111 64-bit unsigned type.
112 \note This type is not available when the compiler
113 option \c -mint8 is in effect. */
114
115typedef unsigned long long int uint64_t;
116
117/**@}*/
118
119#else /* !defined(__DOXYGEN__) */
120
121/* Actual implementation goes here. Define to what built-ins
122 like __UINT32_TYPE__ would resolve to. */
123
124typedef signed char int8_t;
125typedef unsigned char uint8_t;
126
127#if !__USING_MINT8
128
129typedef int int16_t;
130typedef unsigned int uint16_t;
131typedef long int int32_t;
132typedef long unsigned int uint32_t;
133typedef long long int int64_t;
134typedef long long unsigned int uint64_t;
135
136#else /* __USING_MINT8 */
137
138typedef long int int16_t;
139typedef long unsigned int uint16_t;
140typedef long long int int32_t;
141typedef long long unsigned int uint32_t;
142
143#endif /* __USING_MINT8 */
144
145#endif /* defined(__DOXYGEN__) */
146
147/** \name Integer types capable of holding object pointers
148 These allow you to declare variables of the same size as a pointer. */
149
150/**@{*/
151
152/** \ingroup avr_stdint
153 Signed pointer compatible type. */
154
156
157/** \ingroup avr_stdint
158 Unsigned pointer compatible type. */
159
161
162/**@}*/
163
164/** \name Minimum-width integer types
165 Integer types having at least the specified width */
166
167/**@{*/
168
169/** \ingroup avr_stdint
170 signed int with at least 8 bits. */
171
173
174/** \ingroup avr_stdint
175 unsigned int with at least 8 bits. */
176
178
179/** \ingroup avr_stdint
180 signed int with at least 16 bits. */
181
183
184/** \ingroup avr_stdint
185 unsigned int with at least 16 bits. */
186
188
189/** \ingroup avr_stdint
190 signed int with at least 32 bits. */
191
193
194/** \ingroup avr_stdint
195 unsigned int with at least 32 bits. */
196
198
199#if !__USING_MINT8 || defined(__DOXYGEN__)
200/** \ingroup avr_stdint
201 signed int with at least 64 bits.
202 \note This type is not available when the compiler
203 option -mint8 is in effect. */
204
206
207/** \ingroup avr_stdint
208 unsigned int with at least 64 bits.
209 \note This type is not available when the compiler
210 option -mint8 is in effect. */
211
213#endif
214
215/**@}*/
216
217
218/** \name Fastest minimum-width integer types
219 Integer types being usually fastest having at least the specified width */
220
221/**@{*/
222
223/** \ingroup avr_stdint
224 fastest signed int with at least 8 bits. */
225
227
228/** \ingroup avr_stdint
229 fastest unsigned int with at least 8 bits. */
230
232
233/** \ingroup avr_stdint
234 fastest signed int with at least 16 bits. */
235
237
238/** \ingroup avr_stdint
239 fastest unsigned int with at least 16 bits. */
240
242
243/** \ingroup avr_stdint
244 fastest signed int with at least 32 bits. */
245
247
248/** \ingroup avr_stdint
249 fastest unsigned int with at least 32 bits. */
250
252
253#if !__USING_MINT8 || defined(__DOXYGEN__)
254/** \ingroup avr_stdint
255 fastest signed int with at least 64 bits.
256 \note This type is not available when the compiler
257 option -mint8 is in effect. */
258
260
261/** \ingroup avr_stdint
262 fastest unsigned int with at least 64 bits.
263 \note This type is not available when the compiler
264 option -mint8 is in effect. */
265
267#endif
268
269/**@}*/
270
271
272/** \name Greatest-width integer types
273 Types designating integer data capable of representing any value of
274 any integer type in the corresponding signed or unsigned category */
275
276/**@{*/
277
278#if __USING_MINT8
279typedef int32_t intmax_t;
280
281typedef uint32_t uintmax_t;
282#else /* !__USING_MINT8 */
283/** \ingroup avr_stdint
284 largest signed int available. */
285
287
288/** \ingroup avr_stdint
289 largest unsigned int available. */
290
292#endif /* __USING_MINT8 */
293
294/**@}*/
295
296#ifndef __DOXYGEN__
297/* Helping macro */
298#ifndef __CONCAT
299#define __CONCATenate(left, right) left ## right
300#define __CONCAT(left, right) __CONCATenate(left, right)
301#endif
302
303#endif /* !__DOXYGEN__ */
304
305#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
306
307/** \name Limits of specified-width integer types
308 C++ implementations should define these macros only when
309 __STDC_LIMIT_MACROS is defined before <stdint.h> is included */
310
311/**@{*/
312
313/** \ingroup avr_stdint
314 largest positive value an int8_t can hold. */
315
316#define INT8_MAX 0x7f
317
318/** \ingroup avr_stdint
319 smallest negative value an int8_t can hold. */
320
321#define INT8_MIN (-INT8_MAX - 1)
322
323#if __USING_MINT8
324
325#define UINT8_MAX (__CONCAT(INT8_MAX, U) * 2U + 1U)
326
327#define INT16_MAX 0x7fffL
328#define INT16_MIN (-INT16_MAX - 1L)
329#define UINT16_MAX (__CONCAT(INT16_MAX, U) * 2UL + 1UL)
330
331#define INT32_MAX 0x7fffffffLL
332#define INT32_MIN (-INT32_MAX - 1LL)
333#define UINT32_MAX (__CONCAT(INT32_MAX, U) * 2ULL + 1ULL)
334
335#else /* !__USING_MINT8 */
336
337/** \ingroup avr_stdint
338 largest value an uint8_t can hold. */
339
340#define UINT8_MAX (__CONCAT(INT8_MAX, U) * 2U + 1U)
341
342/** \ingroup avr_stdint
343 largest positive value an int16_t can hold. */
344
345#define INT16_MAX 0x7fff
346
347/** \ingroup avr_stdint
348 smallest negative value an int16_t can hold. */
349
350#define INT16_MIN (-INT16_MAX - 1)
351
352/** \ingroup avr_stdint
353 largest value an uint16_t can hold. */
354
355#define UINT16_MAX (__CONCAT(INT16_MAX, U) * 2U + 1U)
356
357/** \ingroup avr_stdint
358 largest positive value an int32_t can hold. */
359
360#define INT32_MAX 0x7fffffffL
361
362/** \ingroup avr_stdint
363 smallest negative value an int32_t can hold. */
364
365#define INT32_MIN (-INT32_MAX - 1L)
366
367/** \ingroup avr_stdint
368 largest value an uint32_t can hold. */
369
370#define UINT32_MAX (__CONCAT(INT32_MAX, U) * 2UL + 1UL)
371
372#endif /* __USING_MINT8 */
373
374/** \ingroup avr_stdint
375 largest positive value an int64_t can hold. */
376
377#define INT64_MAX 0x7fffffffffffffffLL
378
379/** \ingroup avr_stdint
380 smallest negative value an int64_t can hold. */
381
382#define INT64_MIN (-INT64_MAX - 1LL)
383
384/** \ingroup avr_stdint
385 largest value an uint64_t can hold. */
386
387#define UINT64_MAX (__CONCAT(INT64_MAX, U) * 2ULL + 1ULL)
388
389/**@}*/
390
391/** \name Limits of minimum-width integer types */
392/**@{*/
393
394/** \ingroup avr_stdint
395 largest positive value an int_least8_t can hold. */
396
397#define INT_LEAST8_MAX INT8_MAX
398
399/** \ingroup avr_stdint
400 smallest negative value an int_least8_t can hold. */
401
402#define INT_LEAST8_MIN INT8_MIN
403
404/** \ingroup avr_stdint
405 largest value an uint_least8_t can hold. */
406
407#define UINT_LEAST8_MAX UINT8_MAX
408
409/** \ingroup avr_stdint
410 largest positive value an int_least16_t can hold. */
411
412#define INT_LEAST16_MAX INT16_MAX
413
414/** \ingroup avr_stdint
415 smallest negative value an int_least16_t can hold. */
416
417#define INT_LEAST16_MIN INT16_MIN
418
419/** \ingroup avr_stdint
420 largest value an uint_least16_t can hold. */
421
422#define UINT_LEAST16_MAX UINT16_MAX
423
424/** \ingroup avr_stdint
425 largest positive value an int_least32_t can hold. */
426
427#define INT_LEAST32_MAX INT32_MAX
428
429/** \ingroup avr_stdint
430 smallest negative value an int_least32_t can hold. */
431
432#define INT_LEAST32_MIN INT32_MIN
433
434/** \ingroup avr_stdint
435 largest value an uint_least32_t can hold. */
436
437#define UINT_LEAST32_MAX UINT32_MAX
438
439/** \ingroup avr_stdint
440 largest positive value an int_least64_t can hold. */
441
442#define INT_LEAST64_MAX INT64_MAX
443
444/** \ingroup avr_stdint
445 smallest negative value an int_least64_t can hold. */
446
447#define INT_LEAST64_MIN INT64_MIN
448
449/** \ingroup avr_stdint
450 largest value an uint_least64_t can hold. */
451
452#define UINT_LEAST64_MAX UINT64_MAX
453
454/**@}*/
455
456/** \name Limits of fastest minimum-width integer types */
457
458/**@{*/
459
460/** \ingroup avr_stdint
461 largest positive value an int_fast8_t can hold. */
462
463#define INT_FAST8_MAX INT8_MAX
464
465/** \ingroup avr_stdint
466 smallest negative value an int_fast8_t can hold. */
467
468#define INT_FAST8_MIN INT8_MIN
469
470/** \ingroup avr_stdint
471 largest value an uint_fast8_t can hold. */
472
473#define UINT_FAST8_MAX UINT8_MAX
474
475/** \ingroup avr_stdint
476 largest positive value an int_fast16_t can hold. */
477
478#define INT_FAST16_MAX INT16_MAX
479
480/** \ingroup avr_stdint
481 smallest negative value an int_fast16_t can hold. */
482
483#define INT_FAST16_MIN INT16_MIN
484
485/** \ingroup avr_stdint
486 largest value an uint_fast16_t can hold. */
487
488#define UINT_FAST16_MAX UINT16_MAX
489
490/** \ingroup avr_stdint
491 largest positive value an int_fast32_t can hold. */
492
493#define INT_FAST32_MAX INT32_MAX
494
495/** \ingroup avr_stdint
496 smallest negative value an int_fast32_t can hold. */
497
498#define INT_FAST32_MIN INT32_MIN
499
500/** \ingroup avr_stdint
501 largest value an uint_fast32_t can hold. */
502
503#define UINT_FAST32_MAX UINT32_MAX
504
505/** \ingroup avr_stdint
506 largest positive value an int_fast64_t can hold. */
507
508#define INT_FAST64_MAX INT64_MAX
509
510/** \ingroup avr_stdint
511 smallest negative value an int_fast64_t can hold. */
512
513#define INT_FAST64_MIN INT64_MIN
514
515/** \ingroup avr_stdint
516 largest value an uint_fast64_t can hold. */
517
518#define UINT_FAST64_MAX UINT64_MAX
519
520/**@}*/
521
522/** \name Limits of integer types capable of holding object pointers */
523
524/**@{*/
525
526/** \ingroup avr_stdint
527 largest positive value an intptr_t can hold. */
528
529#define INTPTR_MAX INT16_MAX
530
531/** \ingroup avr_stdint
532 smallest negative value an intptr_t can hold. */
533
534#define INTPTR_MIN INT16_MIN
535
536/** \ingroup avr_stdint
537 largest value an uintptr_t can hold. */
538
539#define UINTPTR_MAX UINT16_MAX
540
541/**@}*/
542
543/** \name Limits of greatest-width integer types */
544
545/**@{*/
546
547/** \ingroup avr_stdint
548 largest positive value an intmax_t can hold. */
549
550#define INTMAX_MAX INT64_MAX
551
552/** \ingroup avr_stdint
553 smallest negative value an intmax_t can hold. */
554
555#define INTMAX_MIN INT64_MIN
556
557/** \ingroup avr_stdint
558 largest value an uintmax_t can hold. */
559
560#define UINTMAX_MAX UINT64_MAX
561
562/**@}*/
563
564/** \name Limits of other integer types
565 C++ implementations should define these macros only when
566 __STDC_LIMIT_MACROS is defined before <stdint.h> is included */
567
568/**@{*/
569
570/** \ingroup avr_stdint
571 largest positive value a ptrdiff_t can hold. */
572
573#define PTRDIFF_MAX INT16_MAX
574
575/** \ingroup avr_stdint
576 smallest negative value a ptrdiff_t can hold. */
577
578#define PTRDIFF_MIN INT16_MIN
579
580
581/* Limits of sig_atomic_t */
582/* signal.h is currently not implemented (not avr/signal.h) */
583
584/** \ingroup avr_stdint
585 largest positive value a sig_atomic_t can hold. */
586
587#define SIG_ATOMIC_MAX INT8_MAX
588
589/** \ingroup avr_stdint
590 smallest negative value a sig_atomic_t can hold. */
591
592#define SIG_ATOMIC_MIN INT8_MIN
593
594
595/** \ingroup avr_stdint
596 largest value a size_t can hold. */
597
598#define SIZE_MAX UINT16_MAX
599
600
601#ifndef __DOXYGEN__
602/* Limits of wchar_t */
603/* wchar.h is currently not implemented */
604#ifndef WCHAR_MAX
605#define WCHAR_MAX __WCHAR_MAX__
606#define WCHAR_MIN __WCHAR_MIN__
607#endif
608
609/* Limits of wint_t */
610/* wchar.h is currently not implemented */
611#ifndef WINT_MAX
612#define WINT_MAX __WINT_MAX__
613#define WINT_MIN __WINT_MIN__
614#endif
615#endif /* !__DOXYGEN__ */
616
617
618#endif /* !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) */
619
620#if (!defined __cplusplus || __cplusplus >= 201103L \
621 || defined __STDC_CONSTANT_MACROS)
622
623/** \name Macros for integer constants
624 C++ implementations should define these macros only when
625 __STDC_CONSTANT_MACROS is defined before <stdint.h> is included.
626
627 These definitions are valid for integer constants without suffix and
628 for macros defined as integer constant without suffix */
629
630/* The GNU C preprocessor defines special macros in the implementation
631 namespace to allow a definition that works in #if expressions. */
632#ifdef __INT8_C
633#define INT8_C(c) __INT8_C(c)
634#define INT16_C(c) __INT16_C(c)
635#define INT32_C(c) __INT32_C(c)
636#define INT64_C(c) __INT64_C(c)
637#define UINT8_C(c) __UINT8_C(c)
638#define UINT16_C(c) __UINT16_C(c)
639#define UINT32_C(c) __UINT32_C(c)
640#define UINT64_C(c) __UINT64_C(c)
641#define INTMAX_C(c) __INTMAX_C(c)
642#define UINTMAX_C(c) __UINTMAX_C(c)
643#else
644/** \ingroup avr_stdint
645 define a constant of type int8_t */
646
647#define INT8_C(value) ((int8_t) value)
648
649/** \ingroup avr_stdint
650 define a constant of type uint8_t */
651
652#define UINT8_C(value) ((uint8_t) __CONCAT(value, U))
653
654#if __USING_MINT8
655
656#define INT16_C(value) __CONCAT(value, L)
657#define UINT16_C(value) __CONCAT(value, UL)
658
659#define INT32_C(value) ((int32_t) __CONCAT(value, LL))
660#define UINT32_C(value) ((uint32_t) __CONCAT(value, ULL))
661
662#else /* !__USING_MINT8 */
663
664/** \ingroup avr_stdint
665 define a constant of type int16_t */
666
667#define INT16_C(value) value
668
669/** \ingroup avr_stdint
670 define a constant of type uint16_t */
671
672#define UINT16_C(value) __CONCAT(value, U)
673
674/** \ingroup avr_stdint
675 define a constant of type int32_t */
676
677#define INT32_C(value) __CONCAT(value, L)
678
679/** \ingroup avr_stdint
680 define a constant of type uint32_t */
681
682#define UINT32_C(value) __CONCAT(value, UL)
683
684#endif /* __USING_MINT8 */
685
686/** \ingroup avr_stdint
687 define a constant of type int64_t */
688
689#define INT64_C(value) __CONCAT(value, LL)
690
691/** \ingroup avr_stdint
692 define a constant of type uint64_t */
693
694#define UINT64_C(value) __CONCAT(value, ULL)
695
696/** \ingroup avr_stdint
697 define a constant of type intmax_t */
698
699#define INTMAX_C(value) __CONCAT(value, LL)
700
701/** \ingroup avr_stdint
702 define a constant of type uintmax_t */
703
704#define UINTMAX_C(value) __CONCAT(value, ULL)
705
706#endif /* !__INT8_C */
707
708/**@}*/
709
710#endif /* (!defined __cplusplus || __cplusplus >= 201103L \
711 || defined __STDC_CONSTANT_MACROS) */
712
713
714#endif /* _STDINT_H_ */
int64_t intmax_t
Definition: stdint.h:286
int16_t int_least16_t
Definition: stdint.h:182
unsigned int uint16_t
Definition: stdint.h:91
int64_t int_least64_t
Definition: stdint.h:205
int32_t int_least32_t
Definition: stdint.h:192
uint64_t uintmax_t
Definition: stdint.h:291
uint16_t uintptr_t
Definition: stdint.h:160
unsigned long int uint32_t
Definition: stdint.h:101
uint16_t uint_least16_t
Definition: stdint.h:187
uint16_t uint_fast16_t
Definition: stdint.h:241
uint64_t uint_fast64_t
Definition: stdint.h:266
signed long long int int64_t
Definition: stdint.h:108
int8_t int_fast8_t
Definition: stdint.h:226
uint32_t uint_fast32_t
Definition: stdint.h:251
int32_t int_fast32_t
Definition: stdint.h:246
signed int int16_t
Definition: stdint.h:86
int16_t int_fast16_t
Definition: stdint.h:236
int16_t intptr_t
Definition: stdint.h:155
int8_t int_least8_t
Definition: stdint.h:172
uint64_t uint_least64_t
Definition: stdint.h:212
unsigned char uint8_t
Definition: stdint.h:81
uint32_t uint_least32_t
Definition: stdint.h:197
uint8_t uint_least8_t
Definition: stdint.h:177
uint8_t uint_fast8_t
Definition: stdint.h:231
unsigned long long int uint64_t
Definition: stdint.h:115
signed long int int32_t
Definition: stdint.h:96
signed char int8_t
Definition: stdint.h:76
int64_t int_fast64_t
Definition: stdint.h:259