[R-pkg-devel] C++17

Steve Bronder @bronder @end|ng |rom @tevebronder@com
Sat Jul 31 18:03:26 CEST 2021


Thanks Dirk and Uwe! Mostly thinking out loud, I wonder how open cran would
be to something where if C++17 is not available from the compiler a package
could

1. Have checks in the R code before the call to throw before the function
is called
2. Using macros so that if c++17 is not available you create a C++ function
that just returns something arbitrary but valid so everything compiles.

That feels a bit funky after writing it out but as long as things fail
properly idt it's an invalid pattern

There's also the alternative route like Eigen and Boost to query the
compiler for certain 14/17 features and make macros for those features. See
the example below for defining EIGEN_CONSTEXPR

https://gitlab.com/libeigen/eigen/-/blob/master/Eigen/src/Core/util/Macros.h#L766

This gives some niceties, but things like `if constexpr ()` and class
constructors with deduced templates go out the window.

We've thought about moving up to C++17 for the Stan math library, but we've
been kind of confused on what would make CRAN happy while requiring 17.
Dirk, I think you're right that "enjoy it when you can" is the best option
atm.

Regards,

Steve Bronder
Website: stevebronder.com
Phone: 412-719-1282
Email: sbronder using stevebronder.com



On Sat, Jul 31, 2021 at 6:05 AM Uwe Ligges <ligges using statistik.tu-dortmund.de>
wrote:

>
>
> On 31.07.2021 04:15, Tim Keitt wrote:
> > Kind of figured that out looking around on github. I added a config
> > (borrowed from one of your repos) to test for CXX17. I'm not sure its
> quite
> > working for me yet but I will figure it out. A couple of questions:
> >
> > 1) I had C++17 in the system requirements in the description file but
> might
> > remove it as I hope to make it check without CXX17. Does that have any
> > impact on installation or is it only informative/notification?
>
>
> Well, there is no platform indepednet code for dealing with that field,
> but some parts may be scripted on parts of CRAN.
>
>
>
> > 2) If we need to adjust a package currently on CRAN owing to platform
> > errors, should we keep the version the same or submit with a version
> bump?
>
> Any changes in new submissions need a new version number.
>
> Best,
> Uwe Ligges
>
>
>
>
> > Thanks.
> >
> > THK
> >
> > On Fri, Jul 30, 2021 at 2:06 PM Dirk Eddelbuettel <edd using debian.org>
> wrote:
> >
> >>
> >> Section 2.7.3 'C++ Support' of the R Admin manual says, "C++ is not used
> >> by R
> >> itself, but support is provided ...".  This is all stored from when R
> >> itself
> >> is configure (prior to compiling) and override-able in package
> >> configuration
> >> (Section 2.7.3 covers that) but as that in other places _it all depends
> on
> >> what the user has installed in terms of C++ compilers_.
> >>
> >> So packages need to test. R 4.1.0 ensure that _if_ C++ is present it is
> at
> >> least C++11, R 4.2.0 (aka r-devel now) is currently set to roll this to
> >> C++14.  Which is ... actually rather nice and way better than what had
> >> only a
> >> few short years ago. But local system may still need to look after their
> >> local compilers.  I still get bug reports from folks "blessed" with a
> >> particularl Linux distro that seems to persist long enough so that
> people
> >> aren't even yet at g++ 4.8 or 4.9 (though that environment has
> workarounds
> >> too). Similarly even when R 4.2.0 comes our there will still be people
> >> trying
> >> to build our packages on R 3.6.* or R 3.5.*. Such is life.
> >>
> >> So in short, for my money, _assuming_ C++17 is present is still a wee
> bit
> >> far
> >> out. Test for it, enjoy it when it is present and deal with it if not.
> >>
> >> Dirk
> >>
> >> --
> >> https://dirk.eddelbuettel.com | @eddelbuettel | edd using debian.org
> >>
> >> ______________________________________________
> >> R-package-devel using r-project.org mailing list
> >> https://stat.ethz.ch/mailman/listinfo/r-package-devel
> >>
> >
> >       [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > R-package-devel using r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-package-devel
> >
>
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list