xref: /netbsd/share/man/man3/inttypes.3 (revision 6550d01e)
1.\" $NetBSD: inttypes.3,v 1.2 2010/05/14 02:45:27 joerg Exp $
2.\"
3.\" Copyright (c) 2010 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" This code is derived from software contributed to The NetBSD Foundation
7.\" by Jukka Ruohonen.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28.\" POSSIBILITY OF SUCH DAMAGE.
29.\"
30.Dd March 21, 2010
31.Dt INTTYPES 3
32.Os
33.Sh NAME
34.Nm inttypes
35.Nd standard fixed-size integer types
36.Sh SYNOPSIS
37.In inttypes.h
38.Sh DESCRIPTION
39The
40.In inttypes.h
41header describes a set of format specifier macros aimed to increase
42portability both within and across operating systems.
43It includes the
44.In stdint.h
45header and extends it with additional facilities.
46.Pp
47Each of the following macros expand to a character string literal
48containing the format specifier suitable for use within the format
49argument of a formatted
50.Tn I/O
51function such as
52.Xr printf 3 .
53Each macro contains an identifier (PRI or SCN),
54a conversion specifier, and a possible length modifier.
55.Pp
56The length modifier follows the integer types described in
57.Xr stdint 3 :
58.Bl -column -offset indent \
59"PRIdLEAST64                " \
60"PRIdLEAST64                "
61.It Em int8_t Ta Em uint8_t
62.It Em int16_t Ta Em uint16_t
63.It Em int32_t Ta Em uint32_t
64.It Em int64_t Ta Em uint64_t
65.It Em int_least8_t Ta Em uint_least8_t
66.It Em int_least16_t Ta Em uint_least16_t
67.It Em int_least32_t Ta Em uint_least32_t
68.It Em int_least64_t Ta Em uint_least64_t
69.It Em int_fast8_t Ta Em uint_fast8_t
70.It Em int_fast16_t Ta Em uint_fast16_t
71.It Em int_fast32_t Ta Em uint_fast32_t
72.It Em int_fast64_t Ta Em uint_fast64_t
73.It Em intmax_t Ta Em uintmax_t
74.It Em intptr_t Ta Em uintptr_t
75.El
76.Pp
77The following format specifiers are defined for the
78.Xr fprintf 3
79and
80.Xr fscanf 3
81families, respectively:
82.Bl -column -offset indent \
83"PRIdLEAST64                " \
84"PRIdLEAST64                "
85.It Li PRI?8 Ta Li SCN?8
86.It Li PRI?16 Ta Li SCN?16
87.It Li PRI?32 Ta Li SCN?32
88.It Li PRI?64 Ta Li SCN?64
89.It Li PRI?LEAST8 Ta Li SCN?LEAST8
90.It Li PRI?LEAST16 Ta Li SCN?LEAST16
91.It Li PRI?LEAST32 Ta Li SCN?LEAST32
92.It Li PRI?LEAST64 Ta Li SCN?LEAST64
93.It Li PRI?FAST8 Ta Li SCN?FAST8
94.It Li PRI?FAST16 Ta Li SCN?FAST16
95.It Li PRI?FAST32 Ta Li SCN?FAST32
96.It Li PRI?FAST64 Ta Li SCN?FAST64
97.It Li PRI?MAX Ta Li SCN?MAX
98.It Li PRI?PTR Ta Li SCN?PTR
99.El
100.Pp
101The available conversion specifiers,
102.Dq \&?
103in above, are
104.Em d
105and
106.Em i
107for signed integers and
108.Em o ,
109.Em u ,
110.Em x ,
111and
112.Em X
113for unsigned integers.
114The
115.Em X
116is not available for the
117.Xr fscanf 3
118family.
119Without the length modifier these would correspond with
120.Sy \&%d ,
121.Sy \&%i ,
122.Sy \&%o ,
123.Sy \&%u ,
124.Sy \&%x ,
125and
126.Sy \&%X ,
127respectively.
128.Sh EXAMPLES
129The following example demonstrates typical usage:
130.Bd -literal -offset indent
131uint64_t i = 123;
132
133\&...
134
135(void)printf("i = %"PRIu64"\en", i);
136.Ed
137.Sh SEE ALSO
138.Xr printf 3 ,
139.Xr scanf 3 ,
140.Xr stdint 3
141.Sh STANDARDS
142The
143.In inttypes.h
144header conforms to
145.St -isoC-99
146and
147.St -p1003.1-2001 .
148.Sh HISTORY
149The
150.In inttypes.h
151header was first introduced in
152.Nx 1.6 .
153