libpng build warning on OpenBSD

Theo Buehler <[email protected]> Sun, 12 Aug 2018 12:14:38 -0600 (MDT)
Newsgroups gmane.comp.graphics.png.devel
Message-ID <[email protected]>
Hi,

Building libpng on OpenBSD results in the following minor build warning:

/usr/ports/pobj/png-1.6.35/libpng-1.6.35/contrib/libtests/pngvalid.c:11661:4:
warning: implicit declaration of function 'feenableexcept' is invalid in C99
[-Wimplicit-function-declaration]
         feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);

The problem is that in our fenv.h, feenableexcept() is guarded by
__BSD_VISIBLE which is set to 0 if _POSIX_SOURCE is defined without
_BSD_SOURCE.

The diff below is one way to fix this.

--- contrib/libtests/pngvalid.c.orig	Sun Aug 12 18:39:28 2018
+++ contrib/libtests/pngvalid.c	Sun Aug 12 18:39:35 2018
@@ -21,6 +21,7 @@
 #define _POSIX_SOURCE 1
 #define _ISOC99_SOURCE 1 /* For floating point */
 #define _GNU_SOURCE 1 /* For the floating point exception extension */
+#define _BSD_SOURCE 1 /* For the floating point exception extension */
 
 #include <signal.h>
 #include <stdio.h>

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot