[PROJ] Why is std=gnu89 tested/enabled ?

Dechaux Eric CEN (BCQ STIG) eric.dechaux at gendarmerie.interieur.gouv.fr
Fri Aug 16 05:57:54 PDT 2019


Greetings,

I have been investigating proj 5.2.0 build failure on Solaris 11.3 for 
amd64. At some point the build stops on error because of the NAN being 
not declared :

gcc -DHAVE_CONFIG_H -I. 
-DPROJ_LIB=\"/appli/stig/11.3-20190816-104632/share/proj\" 
-DMUTEX_pthread  -D_FORTIFY_SOURCE=2 -I/usr/include/pcre 
-I/appli/stig/11.3-20190816-104632/include -Wall 
-Wdeclaration-after-statement -Wextra -Winit-self -Wunused-parameter 
-Wmissing-prototypes -Wmissing-declarations -Wformat 
-Werror=format-security -Wno-format-nonliteral -Wlogical-op -Wshadow 
-Werror=vla -Wdeclaration-after-statement -Wdate-time -Wfloat-conversion 
-std=gnu89 -m64 -O2 -fstack-protector-strong -fpic -fPIC 
--param=ssp-buffer-size=4 -I/appli/stig/11.3-20190816-104632/include 
-DHAVE_C99_MATH=1 -MT proj_strtod.o -MD -MP -MF .deps/proj_strtod.Tpo -c 
-o proj_strtod.o proj_strtod.c
gie.c: In function ‘cart_selftest’:
gie.c:2008:20: error: ‘NAN’ undeclared (first use in this function)
      a = proj_coord(NAN, NAN, NAN, NAN);
                     ^
gie.c:2008:20: note: each undeclared identifier is reported only once 
for each function it appears in
make[2]: *** [gie.o] Erreur 1


As the documentation specify a C and C++11 compiler is required I 
changed the CFLAGS to include -std=gnu11. The build and checks run 
without errror. Solaris 11.3 is bundled with GCC 5.3 with uses gnu11 by 
default for C and there should be no reason to force for it on the CFLAGS.

I noticed the configure script detects and automatically adds -std=gnu89 
to the CFLAGS :

     checking whether C compiler accepts -Wdocumentation 
-Wno-documentation-deprecated-sync... no
     checking if -std=gnu89 can be enabled... yes
     checking whether C++ compiler accepts -Wunused-private-field... no


On Solaris this disables the NAN macro as it is C99:

$ cat test.c
#include <stdlib.h>
#include <math.h>

int main (void) {

         float f ;
         f = NAN ;


         exit (EXIT_SUCCESS) ;
}

$ gcc -std=gnu89 test.c
test.c: In function ‘main’:
test.c:7:6: error: ‘NAN’ undeclared (first use in this function)
   f = NAN ;
       ^
test.c:7:6: note: each undeclared identifier is reported only once for 
each function it appears in

$ gcc -std=gnu99 test.c

$ gcc -std=gnu11 test.c



What is the purpose of forcing C standard to gnu89  ?



Thanks.

-- Eric


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: avertissement.txt
URL: <http://lists.osgeo.org/pipermail/proj/attachments/20190816/05a1978e/attachment.txt>


More information about the PROJ mailing list