From 7620d2f2aebe364cdcdd20e123476b7da93eb2b2 Mon Sep 17 00:00:00 2001 From: Thomas Beutlich Date: Thu, 8 Feb 2024 19:59:50 +0100 Subject: [PATCH] #refs #4301 Fix feature check macros for POSIX realpath --- Modelica/Resources/C-Sources/ModelicaInternal.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Modelica/Resources/C-Sources/ModelicaInternal.c b/Modelica/Resources/C-Sources/ModelicaInternal.c index 701cc0d3ed..99c08e7cf8 100644 --- a/Modelica/Resources/C-Sources/ModelicaInternal.c +++ b/Modelica/Resources/C-Sources/ModelicaInternal.c @@ -671,6 +671,13 @@ int ModelicaInternal_getNumberOfFiles(_In_z_ const char* directory) { _Ret_z_ const char* ModelicaInternal_fullPathName(_In_z_ const char* name) { /* Get full path name of file or directory */ +#undef MODELICA_INTERNAL_HAVE_POSIX_REALPATH +#if defined(_BSD_SOURCE) || \ + (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 500) || \ + (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ + _POSIX_VERSION >= 200112L +#define MODELICA_INTERNAL_HAVE_POSIX_REALPATH +#endif #if defined(_WIN32) char* fullName; @@ -684,7 +691,7 @@ _Ret_z_ const char* ModelicaInternal_fullPathName(_In_z_ const char* name) { fullName = ModelicaDuplicateString(tempName); ModelicaConvertToUnixDirectorySeparator(fullName); return fullName; -#elif (_BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED || _POSIX_VERSION >= 200112L) +#elif defined(MODELICA_INTERNAL_HAVE_POSIX_REALPATH) char* fullName; char localbuf[BUFFER_LENGTH]; size_t len; @@ -710,10 +717,10 @@ _Ret_z_ const char* ModelicaInternal_fullPathName(_In_z_ const char* name) { return fullName; #endif -#if (_BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED || _POSIX_VERSION >= 200112L) +#if defined(MODELICA_INTERNAL_HAVE_POSIX_REALPATH) FALLBACK_getcwd: #endif -#if (_BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED || _POSIX_VERSION >= 200112L || _POSIX_) +#if defined(MODELICA_INTERNAL_HAVE_POSIX_REALPATH) || defined(_POSIX_) { /* No such system call in _POSIX_ available (except realpath for existing paths) */ char* cwd = getcwd(localbuf, sizeof(localbuf)); @@ -734,6 +741,7 @@ _Ret_z_ const char* ModelicaInternal_fullPathName(_In_z_ const char* name) { } return fullName; #endif +#undef MODELICA_INTERNAL_HAVE_POSIX_REALPATH } _Ret_z_ const char* ModelicaInternal_temporaryFileName(void) {