Skip to content

Commit 4cb18a4

Browse files
drafnelgitster
authored andcommitted
git-compat-util.h: tweak the way _XOPEN_SOURCE is set on Solaris
On Solaris, when _XOPEN_EXTENDED is set, its header file forces the programs to be XPG4v2, defeating any _XOPEN_SOURCE setting to say we are XPG5 or XPG6. Also on Solaris, XPG6 programs must be compiled with a c99 compiler, while non XPG6 programs must be compiled with a pre-c99 compiler. So when compiling on Solaris, always refrain from setting _XOPEN_EXTENDED, and then set _XOPEN_SOURCE to 600 or 500 based on whether a c99 compiler is being used or not. Signed-off-by: Brandon Casey <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 309dbc8 commit 4cb18a4

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

git-compat-util.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,20 @@
3939
/* Approximation of the length of the decimal representation of this type. */
4040
#define decimal_length(x) ((int)(sizeof(x) * 2.56 + 0.5) + 1)
4141

42-
#if !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) && !defined(_M_UNIX)
42+
#if defined(__sun__)
43+
/*
44+
* On Solaris, when _XOPEN_EXTENDED is set, its header file
45+
* forces the programs to be XPG4v2, defeating any _XOPEN_SOURCE
46+
* setting to say we are XPG5 or XPG6. Also on Solaris,
47+
* XPG6 programs must be compiled with a c99 compiler, while
48+
* non XPG6 programs must be compiled with a pre-c99 compiler.
49+
*/
50+
# if __STDC_VERSION__ - 0 >= 199901L
51+
# define _XOPEN_SOURCE 600
52+
# else
53+
# define _XOPEN_SOURCE 500
54+
# endif
55+
#elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) && !defined(_M_UNIX)
4356
#define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */
4457
#define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */
4558
#endif

0 commit comments

Comments
 (0)