doc: Update for Solaris 11.4.
[gnulib.git] / doc / posix-functions / getcwd.texi
blob07025695d4e66179a381024b97039ec0ed3e8eef
1 @node getcwd
2 @section @code{getcwd}
3 @findex getcwd
5 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/getcwd.html}
7 Gnulib module: getcwd or getcwd-lgpl
9 Portability problems fixed by either Gnulib module @code{getcwd} or
10 @code{getcwd-lgpl}:
11 @itemize
12 @item
13 This function is declared in different header files (namely, @code{<io.h>} or
14 @code{<direct.h>}) on some platforms:
15 mingw, MSVC 14.
16 @item
17 On glibc and Solaris 11.4 platforms,
18 @code{getcwd (NULL, n)} allocates memory for the result.
19 On some other platforms, this call is not allowed.
20 @item
21 On some platforms, the prototype for @code{getcwd} uses @code{int}
22 instead of @code{size_t} for the size argument when using non-standard
23 headers, and the declaration is missing from @code{<unistd.h>}:
24 mingw, MSVC 14.
25 @item
26 On some platforms, @code{getcwd (buf, 0)} fails with @code{ERANGE}
27 instead of the required @code{EINVAL}:
28 mingw, MSVC 14.
29 @end itemize
31 Portability problems fixed by Gnulib module @code{getcwd}:
32 @itemize
33 @item
34 This function is missing on some older platforms.
35 @item
36 This function does not handle long file names (greater than @code{PATH_MAX})
37 correctly on some platforms:
38 glibc on Linux 2.4.20, Mac OS X 10.5, FreeBSD 6.4, NetBSD 5.1, OpenBSD 4.9, AIX 7.1.
39 @end itemize
41 Portability problems not fixed by Gnulib:
42 @itemize
43 @item
44 When using @code{getcwd(NULL, nonzero)}, some platforms, such as glibc
45 or cygwin, allocate exactly @code{nonzero} bytes and fail with
46 @code{ERANGE} if it was not big enough, while other platforms, such as
47 FreeBSD, mingw, or MSVC 14, ignore the size argument and allocate whatever size
48 is necessary.  If this call succeeds, an application cannot portably
49 access beyond the string length of the result.
50 @end itemize