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

Kristian Evers kreve at sdfe.dk
Wed Aug 21 12:57:45 PDT 2019


Markus,

This is all from the past. Currently we don’t enforce any particular standard in the build
scripts, exactly because it tended to create issues for users. We do enforce compilation
of PROJ with C++11 on continuous integration tests to check that we don’t accidentally
use constructs from a newer standard. Additionally, we also test that the C API can be
used in an application that is strictly compiled as C89.

/Kristian

On 21 Aug 2019, at 21:46, Markus Metz <markus.metz.giswork at gmail.com<mailto:markus.metz.giswork at gmail.com>> wrote:



On Wed, Aug 21, 2019 at 2:10 PM Kristian Evers <kreve at sdfe.dk<mailto:kreve at sdfe.dk>> wrote:
>
> No, I don’t think so. Internally PROJ defines some math functions that is first introduced with C99. If the build system detects that they are available with your compiler the system functions are used instead. As far as I remember that is the only difference between using C89

PROJ used -std=gnu89 which is not the same like -std=c89, because only gnu89 includes some C99 features which might not be available on Solaris with -std=gnu89. If PROJ wants to enforce a particular standard, it should probably use -std=c<xy> instead of -std=gnu<xy>, if PROJ is supposed to compile on non-GNU (double negation) systems.

my2c

Markus M


> and C99 to build PROJ 5.2.0. Try running the test suite, it should give you a good indication if it works or not.
>
> /Kristian
>
> On 21 Aug 2019, at 13:55, Dechaux Eric CEN (BCQ STIG) <eric.dechaux at gendarmerie.interieur.gouv.fr<mailto:eric.dechaux at gendarmerie.interieur.gouv.fr>> wrote:
>
> Thanks Kristian,
>
> On Solaris, NAN is not available with C89. Is there an issue to build proj 5 forcing C99 by replacing -std=c89 to -std=c99 in the Makefile, after configure ?
>
>
> Regards.
>
>
> Le 21/08/2019 à 12:43, Kristian Evers a écrit :
>
> Eric,
>
> A C++11 compatible compiler is only required for PROJ 6 and onwards. This was introduced with RFC3 [0]. Previous versions was strictly C89, hence the enforcement of that standard in PROJ 5.2.0.
>
> /Kristian
>
> [0] https://proj.org/community/rfc/rfc-3.html
>
> On 16 Aug 2019, at 14:57, Dechaux Eric CEN (BCQ STIG) <eric.dechaux at gendarmerie.interieur.gouv.fr<mailto:eric.dechaux at gendarmerie.interieur.gouv.fr>> wrote:
>
> 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
>
>
> Ce message �lectronique et tous les fichiers attach�s qu'il contient sont confidentiels et destin�s exclusivement � l'usage de la personne � laquelle ils sont adress�s. Si vous avez re�u ce message par erreur, merci de le retourner � son �metteur. La publication, l'usage, la distribution, l'impression ou la copie non autoris�e de ce message et des attachements qu'il contient sont strictement interdits.
>
> En cas d'urgence, composez le 17 ou le 112.
> Afin de contribuer au respect de l'environnement, merci de n'imprimer cet e-mail qu'en cas de necessite.
>
> This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual to whom it is addressed. If you have received this email in error please send it back to the person that sent it to you. Unauthorized publication, use, dissemination, forwarding, printing or copying of this email and its associated attachments is strictly prohibited.
>
> In case of emergency, dial number 17 or 112.
> To contribute to the environmental protection, please print this e-mail only if necessary.
> _______________________________________________
> PROJ mailing list
> PROJ at lists.osgeo.org<mailto:PROJ at lists.osgeo.org>
> https://lists.osgeo.org/mailman/listinfo/proj
>
>
>
> --
> <signature.png>
> Ce message �lectronique et tous les fichiers attach�s qu'il contient sont confidentiels et destin�s exclusivement � l'usage de la personne � laquelle ils sont adress�s. Si vous avez re�u ce message par erreur, merci de le retourner � son �metteur. La publication, l'usage, la distribution, l'impression ou la copie non autoris�e de ce message et des attachements qu'il contient sont strictement interdits.
>
> En cas d'urgence, composez le 17 ou le 112.
> Afin de contribuer au respect de l'environnement, merci de n'imprimer cet e-mail qu'en cas de necessite.
>
> This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual to whom it is addressed. If you have received this email in error please send it back to the person that sent it to you. Unauthorized publication, use, dissemination, forwarding, printing or copying of this email and its associated attachments is strictly prohibited.
>
> In case of emergency, dial number 17 or 112.
> To contribute to the environmental protection, please print this e-mail only if necessary.
> _______________________________________________
> PROJ mailing list
> PROJ at lists.osgeo.org<mailto:PROJ at lists.osgeo.org>
> https://lists.osgeo.org/mailman/listinfo/proj
>
>
> _______________________________________________
> PROJ mailing list
> PROJ at lists.osgeo.org<mailto:PROJ at lists.osgeo.org>
> https://lists.osgeo.org/mailman/listinfo/proj
_______________________________________________
PROJ mailing list
PROJ at lists.osgeo.org<mailto:PROJ at lists.osgeo.org>
https://lists.osgeo.org/mailman/listinfo/proj

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/proj/attachments/20190821/4cfcc98e/attachment-0001.html>


More information about the PROJ mailing list