From 6d90ddf4a8f6263180949345f510a95af2146606 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 22 Oct 2018 20:01:33 +0200 Subject: document which posix version supports realpath(NULL) --- hurd/porting/guidelines.mdwn | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'hurd') diff --git a/hurd/porting/guidelines.mdwn b/hurd/porting/guidelines.mdwn index 33888685..867b78cb 100644 --- a/hurd/porting/guidelines.mdwn +++ b/hurd/porting/guidelines.mdwn @@ -140,8 +140,15 @@ for a potential corresponding `PATH_MAX` macro. They are not a replacement for Note 2: Yes, some POSIX functions such as `realpath()` actually assume that `PATH_MAX` is defined. This is a bug of the POSIX standard, which got fixed in -the latest revisions, in which one can simply pass `NULL` to get a dynamically -allocated buffer. +POSIX 2001, in which one can simply pass `NULL` to get a dynamically +allocated buffer. One can thus use: + + #if _POSIX_VERSION >= 200112 || defined(__GLIBC__) + char *path = realpath(orig, NULL); + #else + char path[PATH_MATH]; + realpath(orig, path); + #endif ## `ARG_MAX` -- cgit v1.2.3