Add copyright notices to long-enough files that lack them, since
[gnulib.git] / doc / functions.texi
1 @node Function Portability
2 @section Portability of Standard Functions
3 @cindex functions
4
5 @c Copyright (C) 2006 Free Software Foundation, Inc.
6
7 @c Permission is granted to copy, distribute and/or modify this document
8 @c under the terms of the GNU Free Documentation License, Version 1.2 or
9 @c any later version published by the Free Software Foundation; with no
10 @c Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
11 @c Texts.  A copy of the license is included in the ``GNU Free
12 @c Documentation License'' file as part of this distribution.
13
14 Many standard library functions have portability limitations, although
15 they are specified in the
16 @uref{http://www.opengroup.org/susv3, Posix standard}.  In this section,
17 we mention only functions that behave differently than specified; we don't
18 mention functions that are not implemented at all on some platforms, or
19 that are implemented but not declared on some platforms.  Many of the
20 portability problems have a solution in @ref{Gnulib}.
21
22 @table @code
23 @item a64l
24 This function was not correctly implemented in glibc versions before 2.2.5.
25
26 @item accept
27 Some systems don't have a @code{socklen_t} type; in this case this function's
28 third argument type is @samp{int *}.
29
30 @item asctime
31 This function may overflow its internal buffer if an invalid year is passed.
32
33 @item asctime_r
34 This function may put more than 26 bytes into the argument buffer if an
35 invalid year is passed.
36
37 @item basename
38 glibc has two different functions @code{basename}: the POSIX version and
39 the GNU version.
40
41 @code{basename} assumes file names in POSIX syntax; it does not work with file
42 names in Windows syntax.
43
44 @item bcmp
45 This function is marked as ``legacy'' in POSIX.  Better use @code{memcmp}
46 instead.
47
48 @item bcopy
49 This function is marked as ``legacy'' in POSIX.  Better use @code{memcpy}
50 or @code{memmove} instead.
51
52 @item btowc
53 On Windows systems, @code{wchar_t} is a 16-bit type and therefore cannot
54 accommodate all Unicode characters.
55
56 @item bzero
57 This function is marked as ``legacy'' in POSIX.  Better use @code{memset}
58 instead.
59
60 @item chown
61 When applied to a symbolic link, some implementations don't dereference
62 the symlink, i.e.@: they behave like @code{lchown}.
63
64 @item cproj
65 @itemx cprojf
66 @itemx cprojl
67 The glibc implementation is or was broken.
68
69 @item creat
70 On Windows, this function returns a file handle in @code{O_TEXT} mode.  If you
71 need a file handle in @code{O_BINARY} mode, you need to use the function
72 @code{open} instead.
73
74 On platforms where @code{off_t} is a 32-bit type, @code{creat} may not work
75 correctly to create files larger than 2 GB.  The fix is to use the
76 @code{AC_SYS_LARGEFILE} macro.
77
78 @item ctime
79 This function may overflow its internal buffer if an invalid year is passed.
80
81 @item ctime_r
82 This function may put more than 26 bytes into the argument buffer if an
83 invalid year is passed.
84
85 @item dirname
86 @code{dirname} assumes file names in POSIX syntax; it does not work with file
87 names in Windows syntax.
88
89 @item dlopen
90 If the file name argument is not absolute, the file is searched for.  The
91 search algorithm is system specific.
92
93 @item dlsym
94 The visibility of symbols loaded in dependent shared libraries or present
95 in the main executable is system dependent.
96
97 @item ecvt
98 This function is marked as ``legacy'' in POSIX.  Better use @code{sprintf}
99 instead.
100
101 @item errno
102 On Windows, the socket functions don't set @code{errno}; their error code is
103 available through @code{WSAGetLastError()} instead.
104
105 @item fclose
106 On Windows systems (excluding Cygwin), this function does not set @code{errno}
107 upon failure.
108
109 @item fcvt
110 This function is marked as ``legacy'' in POSIX.  Better use @code{sprintf}
111 instead.
112
113 @item fdopen
114 @itemx fflush
115 On Windows systems (excluding Cygwin), these functions do not set @code{errno}
116 upon failure.
117
118 @item fgetc
119 @itemx fgets
120 On Windows systems (excluding Cygwin), these functions do not set @code{errno}
121 upon failure.
122
123 @item fgetwc
124 @itemx fgetws
125 On Windows systems, @code{wchar_t} is a 16-bit type and therefore cannot
126 accommodate all Unicode characters.
127
128 @item fnmatch
129 This function is broken in some version of Solaris or glibc.
130
131 @item fopen
132 On Windows systems (excluding Cygwin), this function does not set @code{errno}
133 upon failure.
134
135 On Windows, this function returns a file stream in ``text'' mode by default;
136 this means that it translates @code{'\n'} to CR/LF by default.  Use the
137 @code{"b"} flag if you need reliable binary I/O.
138
139 @item fork
140 On some systems, @code{fork} followed by a call of the @code{exec} family
141 (@code{execl}, @code{execlp}, @code{execle}, @code{execv}, @code{execvp},
142 or @code{execve}) is less efficient than @code{vfork} followed by the same
143 call.  @code{vfork} is a variant of @code{fork} that has been introduced to
144 optimize the @code{fork}/@code{exec} pattern.
145
146 On Windows systems (excluding Cygwin), this function is not implemented; use
147 @code{spawnvp} instead.
148
149 @item fprintf
150 On NetBSD and Windows, this function doesn't support format directives that
151 access arguments in an arbitrary order, such as @code{"%2$s"}.  The fix is to
152 include @file{<libintl.h>} from GNU gettext; it redefines this function so that
153 it is POSIX compliant.
154
155 On Windows, this function doesn't support the @code{'} flag and the @code{hh},
156 @code{ll}, @code{j}, @code{t}, @code{z} size specifiers.
157
158 @item fputc
159 @itemx fputs
160 On Windows systems (excluding Cygwin), these functions do not set @code{errno}
161 upon failure.
162
163 @item fputwc
164 @itemx fputws
165 On Windows systems, @code{wchar_t} is a 16-bit type and therefore cannot
166 accommodate all Unicode characters.
167
168 @item fread
169 On Windows systems (excluding Cygwin), this function does not set @code{errno}
170 upon failure.
171
172 @item free
173 On old systems, @code{free (NULL)} is not allowed.
174
175 @item freopen
176 On Windows systems (excluding Cygwin), this function does not set @code{errno}
177 upon failure.
178
179 @item fscanf
180 On Windows systems (excluding Cygwin), this function does not set @code{errno}
181 upon failure.
182
183 On Windows, this function doesn't support the @code{hh}, @code{ll}, @code{j},
184 @code{t}, @code{z} size specifiers.
185
186 @item fseek
187 On Windows systems (excluding Cygwin), this function does not set @code{errno}
188 upon failure.
189
190 @item fstat
191 On platforms where @code{off_t} is a 32-bit type, @code{stat} may not correctly
192 report the size of files or block devices larger than 2 GB.  The fix is to
193 use the @code{AC_SYS_LARGEFILE} macro.
194
195 On Cygwin, @code{fstat} applied to the file descriptors 0 and 1, returns
196 different @code{st_ino} values, even if standard input and standard output
197 are not redirected and refer to the same terminal.
198
199 @item ftime
200 This function is marked as ``legacy'' in POSIX.  Better use @code{gettimeofday}
201 or @code{clock_gettime} instead, and use @code{ftime} only as a fallback for
202 portability to Windows systems.
203
204 @item fwide
205 On Windows systems, @code{wchar_t} is a 16-bit type and therefore cannot
206 accommodate all Unicode characters.
207
208 @code{fwide} is not guaranteed to be able to change a file stream's mode
209 to a different mode than the current one.
210
211 @item fwprintf
212 On Windows systems, @code{wchar_t} is a 16-bit type and therefore cannot
213 accommodate all Unicode characters.
214
215 @item fwrite
216 On Windows systems (excluding Cygwin), this function does not set @code{errno}
217 upon failure.
218
219 @item fwscanf
220 On Windows systems, @code{wchar_t} is a 16-bit type and therefore cannot
221 accommodate all Unicode characters.
222
223 @item gcvt
224 This function is marked as ``legacy'' in POSIX.  Better use @code{sprintf}
225 instead.
226
227 @item getaddrinfo
228 On Windows, this function is declared in @code{<ws2tcpip.h>} rather than in
229 @code{<netdb.h>}.
230
231 @item getc
232 @itemx getchar
233 On Windows systems (excluding Cygwin), these functions do not set @code{errno}
234 upon failure.
235
236 @item getcwd
237 On glibc systems, @code{getcwd (NULL, n)} allocates memory for the result.
238 On other systems, this call is not allowed.
239
240 @item getgroups
241 On Ultrix 4.3, @code{getgroups (0, 0)} always fails.  See macro
242 @samp{AC_FUNC_GETGROUPS}.
243
244 @item gethostname
245 If the given buffer is too small for the host name, some implementations
246 fail with @code{EINVAL}, instead of returning a truncated host name.
247
248 @item getopt
249 The default behavior of the glibc implementation of @code{getopt} allows
250 mixing option and non-option arguments on the command line in any order.
251 Other implementations, such as the one in Cygwin, enforce strict POSIX
252 compliance: they require that the option arguments precede the non-option
253 arguments.  This is something to watch out in your program's testsuite.
254
255 @item getpeername
256 Some systems don't have a @code{socklen_t} type; in this case this function's
257 third argument type is @samp{int *}.
258
259 @item getrusage
260 Many systems don't fill in all the fields of @code{struct rusage} with
261 meaningful values.
262
263 @item gets
264 This function should never be used, because it can overflow any given buffer.
265
266 On Windows systems (excluding Cygwin), this function does not set @code{errno}
267 upon failure.
268
269 @item getsockname
270 Some systems don't have a @code{socklen_t} type; in this case this function's
271 third argument type is @samp{int *}.
272
273 @item getsockopt
274 Some systems don't have a @code{socklen_t} type; in this case this function's
275 fifth argument type is @samp{int *}.
276
277 Many socket options are not available on all systems.
278
279 BeOS has the @code{setsockopt} function, but not the @code{getsockopt}
280 function.
281
282 @item gettimeofday
283 On some systems, @code{gettimeofday} clobbers the buffer in which
284 @code{localtime} returns its result.
285
286 @item getwc
287 @itemx getwchar
288 On Windows systems, @code{wchar_t} is a 16-bit type and therefore cannot
289 accommodate all Unicode characters.
290
291 @item getwd
292 The size of the buffer required for this function is not a compile-time
293 constant. Also, the function truncates a result that would be larger than
294 the minimum buffer size. For these reasons, this function is marked as
295 ``legacy'' in POSIX.  Better use the @code{getcwd} function instead.
296
297 @item glob
298 Some systems may store additional flags in the @code{gl_flags} field.
299
300 @item gmtime_r
301 Some systems define a function of this name that is incompatible to POSIX.
302
303 @item iconv
304 This function was not correctly implemented in glibc versions before 2.2.
305
306 When @code{iconv} encounters an input character that is valid but that can
307 not be converted to the output character set, glibc's and GNU libiconv's
308 @code{iconv} stop the conversion.  Some other implementations put an
309 implementation-defined character into the output buffer.
310
311 @item iconv_open
312 The set of supported encodings and conversions is system dependent.
313
314 @item index
315 This function is marked as ``legacy'' in POSIX.  Better use @code{strchr}
316 instead.
317
318 @item inet_addr
319 On some old systems, this function returns a @samp{struct in_addr} rather
320 than a scalar type such as @samp{unsigned int} or @samp{unsigned long}.
321
322 @item ioctl
323 Most @code{ioctl} requests are platform and hardware specific.
324
325 @item isatty
326 On Windows, @code{isatty} also returns true for character devices such as
327 @file{NUL}.
328
329 @item iswalnum
330 @itemx iswalpha
331 @itemx iswblank
332 @itemx iswcntrl
333 @itemx iswctype
334 @itemx iswdigit
335 @itemx iswgraph
336 @itemx iswlower
337 @itemx iswprint
338 @itemx iswpunct
339 @itemx iswspace
340 @itemx iswupper
341 @itemx iswxdigit
342 On Windows systems, @code{wchar_t} is a 16-bit type and therefore cannot
343 accommodate all Unicode characters.
344
345 @item l64a
346 This function was not correctly implemented in glibc versions before 2.2.5.
347
348 @item localtime_r
349 Some systems define a function of this name that is incompatible to POSIX.
350
351 @item longjmp
352 The effects of this call are system and compiler optimization dependent,
353 since it restores the contents of register-allocated variables but not
354 the contents of stack-allocated variables.
355
356 When longjumping out of a signal handler that was being executed on an
357 alternate stack (installed through @code{sigaltstack}), on FreeBSD, NetBSD,
358 OpenBSD, you need to clear the @code{SS_ONSTACK} flag in the @code{stack_t}
359 structure managed by the kernel.
360
361 @item lseek
362 POSIX does not specify which file descriptors support seeking and which don't.
363 In practice, regular files and block devices support seeking, and ttys, pipes,
364 and most character devices don't support it.
365
366 On platforms where @code{off_t} is a 32-bit type, @code{lseek} does not work
367 correctly with files larger than 2 GB.  The fix is to use the
368 @code{AC_SYS_LARGEFILE} macro.
369
370 @item lstat
371 When the argument ends in a slash, some systems don't dereference the
372 argument.
373
374 On platforms where @code{off_t} is a 32-bit type, @code{lstat} may not
375 correctly report the size of files or block devices larger than 2 GB.  The fix
376 is to use the @code{AC_SYS_LARGEFILE} macro.
377
378 On Windows systems (excluding Cygwin), symlinks are not supported, so
379 @code{lstat} does not exist.  The fix is to define lstat to use stat.
380
381 @item mbrtowc
382 @itemx mbsrtowcs
383 @itemx mbstowcs
384 @itemx mbtowc
385 On Windows systems, @code{wchar_t} is a 16-bit type and therefore cannot
386 accommodate all Unicode characters.
387
388 @item mkdir
389 When the argument ends in a slash, the function call fails on some systems.
390
391 On Windows systems (excluding Cygwin), this function is called @code{_mkdir}
392 and takes only one argument.  The fix is to define a macro like this:
393 @smallexample
394 #define mkdir ((int (*)()) _mkdir)
395 @end smallexample
396 or
397 @smallexample
398 #define mkdir(path,mode) _mkdir (path)
399 @end smallexample
400
401 @item mkstemp
402 On some systems (HP-UX 10.20, SunOS 4.1.4, Solaris 2.5.1), mkstemp has a silly
403 limit that it can create no more than 26 files from a given template.  On
404 OSF/1 4.0f, it can create only 32 files per process.
405
406 On systems other than glibc 2.0.7 or newer, @code{mkstemp} can create a
407 world or group writable or readable file, if you haven't set the process
408 umask to 077.  This is a security risk.
409
410 @item mktemp
411 This function is not appropriate for creating temporary files.  (It has
412 security risks.)  Therefore it is marked as ``legacy'' in POSIX.  Better use
413 @code{mkstemp} instead.
414
415 @item mktime
416 Some implementations of @code{mktime} may go into an endless loop.
417
418 @item mmap
419 To get anonymous memory, on some systems, you can use the flags
420 @code{MAP_ANONYMOUS | MAP_PRIVATE} and @code{-1} instead of a file descriptor;
421 on others you have to use a read-only file descriptor of @file{/dev/zero}.
422
423 On HP-UX, passing a non-NULL first argument, as a hint for the address (even
424 without @code{MAP_FIXED}, often causes @code{mmap} to fail.  Better pass NULL
425 in this case.
426
427 On HP-UX, @code{MAP_FIXED} basically never works.  On other systems, it depends
428 on the circumstances whether memory can be returned at a given address.
429
430 @item mprotect
431 On AIX, it is not possible to use @code{mprotect} on memory regions allocated
432 with @code{malloc}.
433
434 @item msync
435 On NetBSD, @code{msync} takes only two arguments.
436
437 @item nanosleep
438
439 @item nice
440 In glibc before glibc 2.2.4, @code{nice} returned 0 upon success.
441
442 @item nl_langinfo
443 Some older versions of glibc had @code{nl_langinfo} but not the @code{CODESET}
444 macro.
445
446 On Cygwin, which doesn't have locales, @code{nl_langinfo(CODESET)} always
447 returns @code{"US-ASCII"}.
448
449 @item open
450 On Windows, this function returns a file handle in @code{O_TEXT} mode by
451 default; this means that it translates '\n' to CR/LF by default.  Use the
452 @code{O_BINARY} flag if you need reliable binary I/O.
453
454 On platforms where @code{off_t} is a 32-bit type, @code{open} may not work
455 correctly with files larger than 2 GB.  The fix is to use the
456 @code{AC_SYS_LARGEFILE} macro.
457
458 @item poll
459 On MacOS X 10.4.0 and AIX 5.3, this function doesn't work on special files
460 like @file{/dev/null} and ttys like @file{/dev/tty}.
461
462 @item printf
463 On NetBSD and Windows, this function doesn't support format directives that
464 access arguments in an arbitrary order, such as @code{"%2$s"}.  The fix is to
465 include @file{<libintl.h>} from GNU gettext; it redefines this function so that
466 it is POSIX compliant.
467
468 On Windows, this function doesn't support the @code{'} flag and the @code{hh},
469 @code{ll}, @code{j}, @code{t}, @code{z} size specifiers.
470
471 @item pthread_create
472 On Linux/glibc systems before the advent of NPTL, signals could only be
473 sent to one particular thread.  In POSIX, signals are sent to the entire
474 process and executed by any thread of the process that happens to have the
475 particular signal currently unblocked.
476
477 @item putc
478 @itemx putchar
479 @itemx puts
480 On Windows systems (excluding Cygwin), these functions do not set @code{errno}
481 upon failure.
482
483 @item putwc
484 @itemx putwchar
485 On Windows systems, @code{wchar_t} is a 16-bit type and therefore cannot
486 accommodate all Unicode characters.
487
488 @item readlink
489 When @code{readlink} is called on a directory: In the case of NFS mounted
490 directories, Cygwin sets @code{errno} to @code{ENOENT} or @code{EIO} instead of
491 @code{EINVAL}.  To avoid this problem, check for a directory before calling
492 @code{readlink}.
493
494 When @code{readlink} is called on a file that is not a symbolic link:
495 Irix may set @code{errno} to @code{ENXIO} instead of @code{EINVAL}.  Cygwin
496 may set errno to @code{EACCES} instead of {EINVAL}.
497
498 @item realpath
499 This function does not allow to determine the required size of output buffer;
500 PATH_MAX --- if it is defined --- is nothing more than a guess.
501
502 @item recvfrom
503 Some systems don't have a @code{socklen_t} type; in this case this function's
504 sixth argument type is @samp{int *}.
505
506 @item regcomp
507 @itemx regexec
508 Many regular expression implementations have bugs.
509
510 @item rename
511 This function does not work on SunOS 4.1 when the source file name ends in a
512 slash.
513
514 @item rewind
515 On Windows systems (excluding Cygwin), this function does not set @code{errno}
516 upon failure.
517
518 @item rindex
519 This function is marked as ``legacy'' in POSIX.  Better use @code{strrchr}
520 instead.
521
522 @item rmdir
523 When @code{rmdir} fails because the specified directory is not empty, the
524 @code{errno} value is system dependent.
525
526 @item scanf
527 On Windows systems (excluding Cygwin), this function does not set @code{errno}
528 upon failure.
529
530 On Windows, this function doesn't support the @code{hh}, @code{ll}, @code{j},
531 @code{t}, @code{z} size specifiers.
532
533 @item select
534 When you call @code{select} with a timeout, some implementations modify the
535 timeout parameter so that upon return from the function, it contains the
536 amount of time not slept.  Other implementations leave the timeout parameter
537 unmodified.
538
539 On Windows systems (excluding Cygwin) and on BeOS, @code{select} can only be
540 called on descriptors created by the @code{socket} function, not on regular
541 file descriptors.
542
543 On Linux, when some file descriptor refers to a regular file, @code{select}
544 may fail, setting @code{errno} to @code{EBADF}.
545
546 @item setcontext
547 The effects of this call are system and compiler optimization dependent,
548 since it restores the contents of register-allocated variables but not
549 the contents of stack-allocated variables.
550
551 @item setenv
552 In some versions of glibc (e.g.@: 2.3.3), @code{setenv} doesn't fail if the
553 first argument contains a @samp{=} character.
554
555 @item setjmp
556 POSIX does not specify whether @code{setjmp} saves the signal mask in the
557 @code{jmp_buf}.  It does on BSD systems, and on glibc systems when
558 @code{_BSD_SOURCE} is defined; in this case @code{setjmp} behaves like
559 @code{sigsetjmp}, and functions @code{_setjmp} and @code{_longjmp} are
560 available that don't save or restore the signal mask.  On System V systems,
561 and on glibc systems by default, @code{setjmp} doesn't save the signal mask.
562
563 @item setlocale
564 On Cygwin, which doesn't have locales, @code{setlocale(LC_ALL,NULL)} always
565 returns @code{"C"}.
566
567 @item setsockopt
568 Many socket options are not available on all systems.
569
570 @item setvbuf
571 On Windows systems (excluding Cygwin), this function does not set @code{errno}
572 upon failure.
573
574 @item shmat
575 Attempts to @code{shmat} into a previously malloc-ed region fail on SunOS 4,
576 with @code{errno} set to @code{EINVAL}, even if there is an @code{munmap} call
577 in between.
578
579 On Linux, the flag @code{SHM_REMAP} is needed in order to force @code{shmat}
580 to replace existing memory mappings in the specify address range.  On other
581 systems, it is not needed.
582
583 @item shmget
584 On many systems (not Linux), SHMMAX is so small that it is unusable for
585 reasonable applications, and/or @code{shmget} requires superuser privileges.
586
587 @item sigaction
588 The symbolic value @code{SIG_IGN} for the @code{SIGCHLD} signal is equivalent
589 to a signal handler
590 @smallexample
591 void handle_child (int sigchld)
592 @{
593   while (waitpid (-1, NULL, WNOHANG) > 0)
594     ;
595 @}
596 @end smallexample
597 except that @code{SIG_IGN} for @code{SIGCHLD} has the effect that the children
598 execution times are not accounted in the @code{times} function.
599 On some systems (BSD? SystemV? Linux?), you need to use the @code{sigaction}
600 flag @code{SA_NOCLDWAIT} in order to obtain this behavior.
601
602 @item sigaltstack
603 @code{sigaltstack} doesn't work on HP-UX 11/IA-64 and OpenBSD 3.6/Sparc64.
604
605 @item signal
606 On System V systems, when the signal is triggered, the kernel uninstalls the
607 handler (i.e.@: resets the signal's action to SIG_DFL) before invoking the
608 handler.  This opens the door to race conditions: undesired things happen
609 if the signal is triggered twice and the signal handler was not quick enough
610 reinstalling itself as a handler.  On BSD systems and glibc systems, on the
611 other hand, when the signal is triggered, the kernel blocks the signal
612 before invoking the handler.  This is saner, but POSIX still allows either
613 behavior.  To avoid this problem, use @code{sigaction} instead of
614 @code{signal}.
615
616 @item sigtimedwait
617 Linux implements the meaning of NULL timeout by doing what @code{sigwaitinfo}
618 does; other systems may not do the same.
619
620 @item sigwait
621 On Linux/glibc systems before the advent of NPTL, signals could only be
622 sent to one particular thread.  In POSIX, signals are sent to the entire
623 process and executed by any thread of the process that happens to have the
624 particular signal currently unblocked.
625
626 @item sleep
627 According to POSIX, the @code{sleep} function may interfere with the program's
628 use of the @code{SIGALRM} signal.  On Linux, it doesn't; on other platforms,
629 it may.
630
631 @item snprintf
632 On NetBSD and Windows, this function doesn't support format directives that
633 access arguments in an arbitrary order, such as @code{"%2$s"}.  The fix is to
634 include @file{<libintl.h>} from GNU gettext; it redefines this function so that
635 it is POSIX compliant.
636
637 On Windows, this function doesn't support the @code{'} flag and the @code{hh},
638 @code{ll}, @code{j}, @code{t}, @code{z} size specifiers.
639
640 @item socket
641 On BeOS, the descriptors returned by the @code{socket} function can not be used
642 in calls to @code{read}, @code{write}, and @code{close}; you have to use
643 @code{recv}, @code{send}, @code{closesocket} in these cases instead.
644
645 @item sprintf
646 On NetBSD and Windows, this function doesn't support format directives that
647 access arguments in an arbitrary order, such as @code{"%2$s"}.  The fix is to
648 include @file{<libintl.h>} from GNU gettext; it redefines this function so that
649 it is POSIX compliant.
650
651 On Windows, this function doesn't support the @code{'} flag and the @code{hh},
652 @code{ll}, @code{j}, @code{t}, @code{z} size specifiers.
653
654 @item sscanf
655 On Windows systems (excluding Cygwin), this function does not set @code{errno}
656 upon failure.
657
658 On Windows, this function doesn't support the @code{hh}, @code{ll}, @code{j},
659 @code{t}, @code{z} size specifiers.
660
661 @item stat
662 On platforms where @code{off_t} is a 32-bit type, @code{stat} may not correctly
663 report the size of files or block devices larger than 2 GB.  The fix is to
664 use the @code{AC_SYS_LARGEFILE} macro.
665
666 Cygwin's @code{stat} function sometimes sets @code{errno} to @code{EACCES} when
667 @code{ENOENT} would be more appropriate.
668
669 @item strcasecmp
670 @itemx strcasestr
671 As of 2006, no system is known that implements these functions correctly in
672 multibyte locales.
673
674 @item strerror_r
675 glibc has an incompatible version of this function.  The POSIX compliant code
676 @smallexample
677 char *s = (strerror_r (err, buf, buflen) == 0 ? buf : NULL);
678 @end smallexample
679 is essentially equivalent to this code using the glibc function:
680 @smallexample
681 char *s = strerror_r (err, buf, buflen);
682 @end smallexample
683
684 @item strstr
685 As of 2006, no system is known that implements this function correctly in
686 multibyte locales.
687
688 @item swprintf
689 On Windows systems, @code{wchar_t} is a 16-bit type and therefore cannot
690 accommodate all Unicode characters.
691
692 On Windows, this function does not take a buffer size as second argument.
693
694 @item system
695 On Windows systems (excluding Cygwin), the command processor used by the
696 @code{system} function is @file{cmd.exe}, not @file{/bin/sh}.  Accordingly,
697 the rules for quoting shell arguments containing spaces, quote or other special
698 characters are different.
699
700 @item tcdrain
701 On some systems, @code{tcdrain} on a non-tty fails with @code{errno} set to
702 @code{EINVAL} or, on MacOS X, also @code{EOPNOTSUPP} or @code{ENODEV}, rather
703 than @code{ENOTTY}.
704
705 @item tcflush
706 On some systems, @code{tcflush} of @code{TCIFLUSH} on a non-tty fails with
707 errno set to @code{EINVAL} rather than @code{ENOTTY}.
708
709 On some systems, @code{tcflush} of @code{TCOFLUSH} on a non-tty fails with
710 errno set to @code{EINVAL} or, on IRIX, also @code{ENOSYS}, or, on MacOS X,
711 also @code{EOPNOTSUPP} or @code{ENODEV}, rather than @code{ENOTTY}.
712
713 @item tempnam
714 This function is not appropriate for creating temporary files.  (It has
715 security risks.)  Better use @code{mkstemp} instead.
716
717 @item tmpnam
718 This function is not appropriate for creating temporary files.  (It has
719 security risks.)  Better use @code{mkstemp} instead.
720
721 @item towctrans
722 @itemx towlower
723 @itemx towupper
724 On Windows systems, @code{wchar_t} is a 16-bit type and therefore cannot
725 accommodate all Unicode characters.
726
727 @item ungetc
728 On Windows systems (excluding Cygwin), this function does not set @code{errno}
729 upon failure.
730
731 @item ungetwc
732 On Windows systems, @code{wchar_t} is a 16-bit type and therefore cannot
733 accommodate all Unicode characters.
734
735 @item unlink
736 Removing an open file is non-portable: On Unix this allows the programs that
737 have the file already open to continue working with it; the file's storage
738 is only freed when the no process has the file open any more.  On Windows,
739 the attempt to remove an open file fails.
740
741 @item usleep
742 According to POSIX, the @code{usleep} function may interfere with the program's
743 use of the @code{SIGALRM} signal.  On Linux, it doesn't; on other platforms,
744 it may.
745
746 @item utime
747 On some systems, @code{utime (file, NULL)} fails to set the file's timestamp
748 to the current time.
749
750 @item utimes
751 This function is marked as ``legacy'' in POSIX.  Better use @code{utime}
752 instead.
753
754 @item va_arg
755 The second argument of @code{va_arg} must be a type that is invariant under
756 the ``default argument promotions'' (ISO C 99 6.5.2.2 paragraph 6).  This
757 means that the following are not valid here:
758 @table @asis
759 @item @samp{float}
760 Use @samp{double} instead.
761 @item @samp{bool}
762 Use @samp{int} instead.
763 @item Integer types smaller than @samp{int}.
764 Use @samp{int} or @samp{unsigned int} instead.
765 @end table
766
767 This is a portability problem because you don't know the width of some
768 abstract types like @code{uid_t}, @code{gid_t}, @code{mode_t}.  So, instead of
769 @smallexample
770 mode = va_arg (ap, mode_t);
771 @end smallexample
772 you have to write
773 @smallexample
774 mode = (sizeof (mode_t) < sizeof (int)
775         ? va_arg (ap, int)
776         : va_arg (ap, mode_t));
777 @end smallexample
778
779 @item va_copy
780 Some platforms don't provide this macro.  You can use __va_copy where
781 available instead, or otherwise an assignment or @code{memcpy} call.
782
783 @item vfprintf
784 On NetBSD and Windows, this function doesn't support format directives that
785 access arguments in an arbitrary order, such as @code{"%2$s"}.  The fix is to
786 include @file{<libintl.h>} from GNU gettext; it redefines this function so that
787 it is POSIX compliant.
788
789 On Windows, this function doesn't support the @code{'} flag and the @code{hh},
790 @code{ll}, @code{j}, @code{t}, @code{z} size specifiers.
791
792 @item vfscanf
793 On Windows systems (excluding Cygwin), this function does not set @code{errno}
794 upon failure.
795
796 On Windows, this function doesn't support the @code{hh}, @code{ll}, @code{j},
797 @code{t}, @code{z} size specifiers.
798
799 @item vprintf
800 @itemx vsnprintf
801 @itemx vsprintf
802 On NetBSD and Windows, these functions don't support format directives that
803 access arguments in an arbitrary order, such as @code{"%2$s"}.  The fix is to
804 include @file{<libintl.h>} from GNU gettext; it redefines these functions so
805 that they are POSIX compliant.
806
807 On Windows, these functions don't support the @code{'} flag and the @code{hh},
808 @code{ll}, @code{j}, @code{t}, @code{z} size specifiers.
809
810 @item vscanf
811 @item vsscanf
812 On Windows systems (excluding Cygwin), these functions do not set @code{errno}
813 upon failure.
814
815 On Windows, these functions don't support the @code{hh}, @code{ll}, @code{j},
816 @code{t}, @code{z} size specifiers.
817
818 @item vswprintf
819 On Windows systems, @code{wchar_t} is a 16-bit type and therefore cannot
820 accommodate all Unicode characters.
821
822 On Windows, this function does not take a buffer size as second argument.
823
824 @item waitid
825 As of 2005, no system is known on which @code{waitid} with flag @code{WNOWAIT}
826 works correctly.
827
828 @item wcrtomb
829 @itemx wcscat
830 @itemx wcschr
831 @itemx wcscmp
832 @itemx wcscoll
833 @itemx wcscpy
834 @itemx wcscspn
835 @itemx wcsftime
836 @itemx wcslen
837 @itemx wcsncat
838 @itemx wcsncmp
839 @itemx wcsncpy
840 @itemx wcspbrk
841 @itemx wcsrchr
842 @itemx wcsrtombs
843 @itemx wcsspn
844 @itemx wcsstr
845 @itemx wcstod
846 @itemx wcstof
847 @itemx wcstoimax
848 @itemx wcstok
849 @itemx wcstol
850 @itemx wcstold
851 @itemx wcstoll
852 @itemx wcstombs
853 @itemx wcstoul
854 @itemx wcstoull
855 @itemx wcstoumax
856 On Windows systems, @code{wchar_t} is a 16-bit type and therefore cannot
857 accommodate all Unicode characters.
858
859 @item wcswcs
860 On Windows systems, @code{wchar_t} is a 16-bit type and therefore cannot
861 accommodate all Unicode characters.
862
863 This function is marked as ``legacy'' in POSIX.  Better use @code{wcsstr}
864 instead.
865
866 @item wcswidth
867 @itemx wcsxfrm
868 @itemx wctob
869 @itemx wctomb
870 @itemx wctrans
871 @itemx wctype
872 @itemx wcwidth
873 @itemx wmemchr
874 @itemx wmemcmp
875 @itemx wmemcpy
876 @itemx wmemmove
877 @itemx wmemset
878 @itemx wprintf
879 @itemx wscanf
880 On Windows systems, @code{wchar_t} is a 16-bit type and therefore cannot
881 accommodate all Unicode characters.
882
883 @end table