getcwd
======

POSIX specification:
 https://pubs.opengroup.org/onlinepubs/9699919799/functions/getcwd.html

Gnulib module: getcwd or getcwd-lgpl

Portability problems fixed by either Gnulib module getcwd or getcwd-lgpl:

  * This function is declared in different header files (namely, <io.h> or <direct.h>) on some platforms: mingw, MSVC 14.

  * On glibc and Solaris 11.4 platforms, getcwd (NULL, n) allocates memory for the result. On some other platforms, this call is not allowed.

  * On some platforms, the prototype for getcwd uses int instead of size_t for the size argument when using non-standard headers, and the declaration is missing from <unistd.h>: mingw, MSVC 14.

  * On some platforms, getcwd (buf, 0) crashes: MSVC 14.

  * On some platforms, getcwd (buf, 0) fails with ERANGE instead of the required EINVAL: mingw.

Portability problems fixed by Gnulib module getcwd:

  * This function is missing on some older platforms.

  * This function does not handle long file names (greater than PATH_MAX) correctly on some platforms: glibc on Linux 2.4.20, Mac OS X 10.5, FreeBSD 6.4, NetBSD 5.1, OpenBSD 4.9, AIX 7.1.

Portability problems not fixed by Gnulib:

  * When using getcwd(NULL, nonzero), some platforms, such as glibc or cygwin, allocate exactly nonzero bytes and fail with ERANGE if it was not big enough, while other platforms, such as FreeBSD, mingw, or MSVC 14, ignore the size argument and allocate whatever size is necessary.  If this call succeeds, an application cannot portably access beyond the string length of the result.