poll tests: Avoid test failure on BSD and Solaris systems.
[gnulib.git] / doc / posix-functions / snprintf.texi
blob756a6d5473cbe9b3599d539409e0a6a10e5f5d96
1 @node snprintf
2 @section @code{snprintf}
3 @findex snprintf
5 POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9699919799/functions/snprintf.html}
7 Gnulib module: snprintf or snprintf-posix
9 Portability problems fixed by either Gnulib module @code{snprintf} or @code{snprintf-posix}:
10 @itemize
11 @item
12 This function is missing on some platforms:
13 MSVC 14.
14 @item
15 This function does not support format directives that access arguments in an
16 arbitrary order, such as @code{"%2$s"}, on some platforms:
17 NetBSD 3.0, mingw.
18 @item
19 This function does not return a byte count as specified in C99 on some
20 platforms:
21 HP-UX 11, IRIX 6.5, Solaris 9, mingw.
22 @end itemize
24 Portability problems fixed by Gnulib module @code{snprintf-posix}:
25 @itemize
26 @item
27 This function does not support size specifiers as in C99 (@code{hh}, @code{ll},
28 @code{j}, @code{t}, @code{z}) on some platforms:
29 AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9, Cygwin 1.5.24, mingw, MSVC 14.
30 @item
31 printf of @samp{long double} numbers is unsupported on some platforms:
32 mingw, MSVC 14.
33 @item
34 printf @code{"%f"}, @code{"%e"}, @code{"%g"} of Infinity and NaN yields an
35 incorrect result on some platforms:
36 AIX 5.2, Solaris 11.4, mingw, MSVC 14.
37 @item
38 This function does not support the @samp{a} and @samp{A} directives on some
39 platforms:
40 glibc-2.3.6, Mac OS X 10.5, NetBSD 9.0, OpenBSD 4.0, AIX 5.2, HP-UX 11,
41 IRIX 6.5, Solaris 11.4, Cygwin 1.5.x, mingw, MSVC 14.
42 @item
43 This function does not support the @samp{F} directive on some platforms:
44 NetBSD 3.0, AIX 5.1, HP-UX 11.23, IRIX 6.5, Solaris 9,
45 Cygwin 1.5.x, mingw, MSVC 14.
46 @item
47 This function does not support the @samp{n} directive on some platforms:
48 glibc when used with @code{_FORTIFY_SOURCE >= 2} (set by default on Ubuntu),
49 Mac OS X 10.13, MSVC 14.
50 @item
51 This function does not support the @samp{ls} directive on some platforms:
52 OpenBSD 4.0, IRIX 6.5, Cygwin 1.5.x, Haiku.
53 @item
54 This function does not support precisions in the @samp{ls} directive correctly
55 on some platforms:
56 Solaris 11.4.
57 @item
58 This function doesn't support the @code{'} flag on some platforms:
59 NetBSD 3.0, Cygwin 1.5.24, mingw, MSVC 14.
60 @item
61 This function does not round the argument of the @samp{a} directive correctly
62 on some platforms:
63 Mac OS X 10.12, FreeBSD 6.1.
64 @item
65 printf @code{"%010f"} of NaN and Infinity yields an incorrect result (padded
66 with zeroes, or wrong capitalization) on some platforms:
67 Mac OS X 10.5, FreeBSD 6.0, NetBSD 5.0, AIX 5.2, IRIX 6.5, Solaris 11.4, Cygwin 1.5.x, mingw, MSVC/clang.
68 @item
69 This function does not support precisions larger than 512 or 1024 in integer,
70 floating-point and pointer output on some platforms:
71 AIX 7.1, Solaris 10/x86, mingw, MSVC/clang.
72 @item
73 This function mishandles large floating point precisions
74 (for example, formatting 1.0 with @samp{"%.511f"})
75 on some platforms:
76 Solaris 10.
77 @item
78 This function can crash in out-of-memory conditions on some platforms:
79 FreeBSD 6.0, NetBSD 5.0.
80 @item
81 This function does not truncate the result as specified in C99 on some platforms:
82 mingw, MSVC 14.
83 @item
84 This function does not fully support the @samp{n} directive on some platforms:
85 HP-UX 11, mingw, MSVC 14.
86 @end itemize
88 Portability problems not fixed by Gnulib:
89 @itemize
90 @item
91 The @code{%m} directive is not portable, use @code{%s} mapped to an
92 argument of @code{strerror(errno)} (or a version of @code{strerror_r})
93 instead.
94 @item
95 Formatting noncanonical @samp{long double} numbers produces
96 nonmeaningful results on some platforms:
97 glibc and others, on x86, x86_64, IA-64 CPUs.
98 @item
99 When formatting an integer with grouping flag, this function inserts thousands
100 separators even in the "C" locale on some platforms:
101 NetBSD 5.1.
102 @end itemize