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