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