From @ndre@@ @end|ng |rom @ker@t|ng@de  Fri Oct  2 19:34:14 2020
From: @ndre@@ @end|ng |rom @ker@t|ng@de (Andreas Kersting)
Date: Fri, 02 Oct 2020 19:34:14 +0200 (CEST)
Subject: [Rd] Specifying C Standard in Package's Makevars File
In-Reply-To: <2c6908ad-a9e9-da16-4c6a-3f8dd7601b4d@stats.ox.ac.uk>
Message-ID: <E1kOOwg-00045W-NW@rmmprod07.runbox>

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
> 


[Rd] Specifying C Standard in Package's Makevars File
Andreas Kersting