Andreas Kersting
2020-Sep-28 11:44 UTC
[Rd] Specifying C Standard in Package's Makevars File
Hi, what is the correct way to specify a C standard in a package's Makevars file? Building a package with e.g. PKG_CFLAGS = -std=gnu11 does work but R CMD check issues a warning: * checking compilation flags in Makevars ... WARNING Non-portable flags in variable 'PKG_CFLAGS': -std=gnu11 (Same for -std=c11.) Thanks! Regards, Andreas Kersting
WRE explains for C++11 14 etc standards but I don't know about C https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Using-C_002b_002b11-code BTW I believe this question would be more appropriate for R-package-devel. On Mon, Sep 28, 2020 at 4:44 AM Andreas Kersting <r-devel at akersting.de> wrote:> Hi, > > what is the correct way to specify a C standard in a package's Makevars > file? > > Building a package with e.g. PKG_CFLAGS = -std=gnu11 does work but R CMD > check issues a warning: > > * checking compilation flags in Makevars ... WARNING > Non-portable flags in variable 'PKG_CFLAGS': > -std=gnu11 > > (Same for -std=c11.) > > Thanks! Regards, > Andreas Kersting > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >[[alternative HTML version deleted]]
Prof Brian Ripley
2020-Sep-29 14:35 UTC
[Rd] Specifying C Standard in Package's Makevars File
On 28/09/2020 12:44, Andreas Kersting wrote:> Hi, > > what is the correct way to specify a C standard in a package's Makevars file? > > Building a package with e.g. PKG_CFLAGS = -std=gnu11 does work but R CMD check issues a warning:for some unstated value of 'work' ...> * checking compilation flags in Makevars ... WARNING > Non-portable flags in variable 'PKG_CFLAGS': > -std=gnu11 > > (Same for -std=c11.) > > Thanks! Regards, > Andreas KerstingThose flags are not portable, as 'check' correctly says. Furthermore, on some platforms there may be no flag which can be added -- R documents that 'CC' specifies a C99 compiler, and that or CC+CFLAGS are likely to specify flags which are incompatible with -std=c11 (true on Solaris where -xc99 is used). So, like all such overrides (see 'Writing R Extensions') you need to write a configure script (preferably using autoconf) to - select an appropriate C compiler+flags - substitute them into src/Makefile.in For the new features I have used in C11, all known compilers make them available in C99 mode and a configure script could be used to test for their presence (as R itself does). That is, it is rare to actually need to specify C11 mode. -- Brian D. Ripley, ripley at stats.ox.ac.uk Emeritus Professor of Applied Statistics, University of Oxford
Andreas Kersting
2020-Oct-02 17:34 UTC
[Rd] Specifying C Standard in Package's Makevars File
Thanks, that was very helpful. The C11 features I use do actually work in C99 mode, so I will stick with that. I just thought it was kind of "cleaner" to specify C11 mode when using features from that standard. 2020-09-29 16:35 GMT+02:00 "Prof Brian Ripley" <ripley at stats.ox.ac.uk>:> On 28/09/2020 12:44, Andreas Kersting wrote:> Hi, >> > what is the correct way to specify a C standard in a package's Makevars file? >> > Building a package with e.g. PKG_CFLAGS = -std=gnu11 does work but R CMD check issues a warning: > > for some unstated value of 'work' ... > >> * checking compilation flags in Makevars ... WARNING >> Non-portable flags in variable 'PKG_CFLAGS': >> -std=gnu11 >> > (Same for -std=c11.) >> > Thanks! Regards, >> Andreas Kersting > > Those flags are not portable, as 'check' correctly says. Furthermore, on some platforms there may be no flag which can be added -- R documents that 'CC' specifies a C99 compiler, and that or CC+CFLAGS are likely to specify flags which are incompatible with -std=c11 (true on Solaris where -xc99 is used). > > So, like all such overrides (see 'Writing R Extensions') you need to write a configure script (preferably using autoconf) to > > - select an appropriate C compiler+flags > - substitute them into src/Makefile.in > > For the new features I have used in C11, all known compilers make them available in C99 mode and a configure script could be used to test for their presence (as R itself does). That is, it is rare to actually need to specify C11 mode. > > -- > Brian D. Ripley, ripley at stats.ox.ac.uk > Emeritus Professor of Applied Statistics, University of Oxford > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel >