Specifying C Standard in Package's Makevars File

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Specifying C Standard in Package's Makevars File

Andreas Kersting
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
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Specifying C Standard in Package's Makevars File

Toby Hocking-2
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 <[hidden email]>
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
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Specifying C Standard in Package's Makevars File

Prof Brian Ripley
In reply to this post by Andreas Kersting
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,                  [hidden email]
Emeritus Professor of Applied Statistics, University of Oxford

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: Specifying C Standard in Package's Makevars File

Andreas Kersting-2
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" <[hidden email]>:

> 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,                  [hidden email]
> Emeritus Professor of Applied Statistics, University of Oxford
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel