[tlbuild] Bug in libpng affecting Solaris 10
Mojca Miklavec
mojca.miklavec.lists at gmail.com
Tue Jan 19 16:08:28 CET 2016
On 19 January 2016 at 15:20, Mojca Miklavec wrote:
>
> Meanwhile I came up with a minimal example that fails to compile:
>
> #define _POSIX_SOURCE 1
> #include <stdio.h>
> void main() {}
>
> I managed to compile libpng if I remove
> #define _POSIX_SOURCE 1
> from three files (pngpriv.h, pngtest.c, contrib/libtests/pngvalid.c).
Below are fragments from the header file emitting the failure. It
seems that any code with _POSIX_SOURCE defined will almost always fail
with GCC 5.x unless one of these three variables is defined:
- _XPG6
- _XOPEN_SOURCE == 600
- _POSIX_C_SOURCE == 200112L
Mojca
-----------------
/*
* Values of _POSIX_C_SOURCE
*
* undefined not a POSIX compilation
* 1 POSIX.1-1990 compilation
* 2 POSIX.2-1992 compilation
* 199309L POSIX.1b-1993 compilation (Real Time)
* 199506L POSIX.1c-1995 compilation (POSIX Threads)
* 200112L POSIX.1-2001 compilation (Austin Group Revision)
*/
#if defined(_POSIX_SOURCE) && !defined(_POSIX_C_SOURCE)
#define _POSIX_C_SOURCE 1
#endif
/*
* The feature test macros __XOPEN_OR_POSIX, _STRICT_STDC, and _STDC_C99
* are Sun implementation specific macros created in order to compress
* common standards specified feature test macros for easier reading.
* These macros should not be used by the application developer as
* unexpected results may occur. Instead, the user should reference
* standards(5) for correct usage of the standards feature test macros.
*
* __XOPEN_OR_POSIX Used in cases where a symbol is defined by both
* X/Open or POSIX or in the negative, when neither
* X/Open or POSIX defines a symbol.
*
* _STRICT_STDC __STDC__ is specified by the C Standards and defined
* by the compiler. For Sun compilers the value of
* __STDC__ is either 1, 0, or not defined based on the
* compilation mode (see cc(1)). When the value of
* __STDC__ is 1 and in the absence of any other feature
* test macros, the namespace available to the application
* is limited to only those symbols defined by the C
* Standard. _STRICT_STDC provides a more readable means
* of identifying symbols defined by the standard, or in
* the negative, symbols that are extensions to the C
* Standard. See additional comments for GNU C differences.
*
* _STDC_C99 __STDC_VERSION__ is specified by the C standards and
* defined by the compiler and indicates the version of
* the C standard. A value of 199901L indicates a
* compiler that complies with ISO/IEC 9899:1999, other-
* wise known as the C99 standard.
*/
#if defined(_XOPEN_SOURCE) || defined(_POSIX_C_SOURCE)
#define __XOPEN_OR_POSIX
#endif
/* X/Open Portability Guide, Issue 3 */
#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 < 500) && \
(_XOPEN_VERSION - 0 < 4) && !defined(_XOPEN_SOURCE_EXTENDED)
#define _XPG3
/* X/Open CAE Specification, Issue 4 */
#elif (defined(_XOPEN_SOURCE) && _XOPEN_VERSION - 0 == 4)
#define _XPG4
#define _XPG3
/* X/Open CAE Specification, Issue 4, Version 2 */
#elif (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE_EXTENDED - 0 == 1)
#define _XPG4_2
#define _XPG4
#define _XPG3
/* X/Open CAE Specification, Issue 5 */
#elif (_XOPEN_SOURCE - 0 == 500)
#define _XPG5
#define _XPG4_2
#define _XPG4
#define _XPG3
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 199506L
/* Open Group Technical Standard , Issue 6 */
#elif (_XOPEN_SOURCE - 0 == 600) || (_POSIX_C_SOURCE - 0 == 200112L)
#define _XPG6
#define _XPG5
#define _XPG4_2
#define _XPG4
#define _XPG3
#undef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200112L
#undef _XOPEN_SOURCE
#define _XOPEN_SOURCE 600
#endif
/*
* It is invalid to compile an XPG3, XPG4, XPG4v2, or XPG5 application
* using c99. The same is true for POSIX.1-1990, POSIX.2-1992, POSIX.1b,
* and POSIX.1c applications. Likewise, it is invalid to compile an XPG6
* or a POSIX.1-2001 application with anything other than a c99 or later
* compiler. Therefore, we force an error in both cases.
*/
#if defined(_STDC_C99) && (defined(__XOPEN_OR_POSIX) && !defined(_XPG6))
#error "Compiler or options invalid for pre-UNIX 03 X/Open applications \
and pre-2001 POSIX applications"
#elif !defined(_STDC_C99) && \
(defined(__XOPEN_OR_POSIX) && defined(_XPG6))
#error "Compiler or options invalid; UNIX 03 and POSIX.1-2001 applications \
require the use of c99"
#endif
More information about the tlbuild
mailing list