Skip to content

Commit 714237b

Browse files
authored
#refs #4301 Fix feature check macros for POSIX realpath (#4530)
1 parent a1abb9c commit 714237b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Modelica/Resources/C-Sources/ModelicaInternal.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,13 @@ int ModelicaInternal_getNumberOfFiles(_In_z_ const char* directory) {
671671

672672
_Ret_z_ const char* ModelicaInternal_fullPathName(_In_z_ const char* name) {
673673
/* Get full path name of file or directory */
674+
#undef MODELICA_INTERNAL_HAVE_POSIX_REALPATH
675+
#if defined(_BSD_SOURCE) || \
676+
(defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 500) || \
677+
(defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \
678+
_POSIX_VERSION >= 200112L
679+
#define MODELICA_INTERNAL_HAVE_POSIX_REALPATH
680+
#endif
674681

675682
#if defined(_WIN32)
676683
char* fullName;
@@ -684,7 +691,7 @@ _Ret_z_ const char* ModelicaInternal_fullPathName(_In_z_ const char* name) {
684691
fullName = ModelicaDuplicateString(tempName);
685692
ModelicaConvertToUnixDirectorySeparator(fullName);
686693
return fullName;
687-
#elif (_BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED || _POSIX_VERSION >= 200112L)
694+
#elif defined(MODELICA_INTERNAL_HAVE_POSIX_REALPATH)
688695
char* fullName;
689696
char localbuf[BUFFER_LENGTH];
690697
size_t len;
@@ -710,10 +717,10 @@ _Ret_z_ const char* ModelicaInternal_fullPathName(_In_z_ const char* name) {
710717
return fullName;
711718
#endif
712719

713-
#if (_BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED || _POSIX_VERSION >= 200112L)
720+
#if defined(MODELICA_INTERNAL_HAVE_POSIX_REALPATH)
714721
FALLBACK_getcwd:
715722
#endif
716-
#if (_BSD_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED || _POSIX_VERSION >= 200112L || _POSIX_)
723+
#if defined(MODELICA_INTERNAL_HAVE_POSIX_REALPATH) || defined(_POSIX_)
717724
{
718725
/* No such system call in _POSIX_ available (except realpath for existing paths) */
719726
char* cwd = getcwd(localbuf, sizeof(localbuf));
@@ -734,6 +741,7 @@ _Ret_z_ const char* ModelicaInternal_fullPathName(_In_z_ const char* name) {
734741
}
735742
return fullName;
736743
#endif
744+
#undef MODELICA_INTERNAL_HAVE_POSIX_REALPATH
737745
}
738746

739747
_Ret_z_ const char* ModelicaInternal_temporaryFileName(void) {

0 commit comments

Comments
 (0)