[R-pkg-devel] length() conflict with C++17

Gábor Csárdi c@@rd|@g@bor @end|ng |rom gm@||@com
Fri Jun 30 11:49:34 CEST 2023


Yeah, I think both `R_NO_REMAP` and rearranging the includes are good
solutions, personally I would do both.

There is a container at https://r-hub.github.io/containers/ if you
want to make sure that you fixed everything:
docker run -ti ghcr.io/r-hub/containers/clang17 bash

Or, you can try the new rhub2 package, which uses the same container on GHA:
https://github.com/r-hub/rhub2#readme

Best,
Gabor


On Fri, Jun 30, 2023 at 11:39 AM Duncan Murdoch
<murdoch.duncan using gmail.com> wrote:
>
> rgl has a lot of C++ code which is now getting errors in the clang17
> tests on CRAN:
>
>    https://www.stats.ox.ac.uk/pub/bdr/clang17/rgl.log
>
> I haven't looked at the whole list yet, but many of the errors arise
> because R's include/Rinternals.h defines a length() macro, and that
> conflicts with a definition in clang's library.  For example,
>
>   /lib64/glib-2.0/include -I/usr/include/sysprof-4 -pthread  -Iext
> -Iext/glad/include  -isystem /usr/local/clang-trunk/include
> -I/usr/local/clang/include    -fpic  -O3 -Wall -pedantic -frtti
> -Wp,-D_FORTIFY_SOURCE=3  -c PlaneSet.cpp -o PlaneSet.o
>   In file included from NULLgui.cpp:9:
>   In file included from ./NULLgui.h:4:
>   In file included from ./gui.h:9:
>   In file included from ./glgui.h:8:
>   In file included from
> /usr/local/clang-trunk/bin/../include/c++/v1/vector:322:
>   In file included from
> /usr/local/clang-trunk/bin/../include/c++/v1/__format/formatter_bool.h:21:
>   In file included from
> /usr/local/clang-trunk/bin/../include/c++/v1/__format/formatter_integral.h:32:
>   In file included from
> /usr/local/clang-trunk/bin/../include/c++/v1/locale:203:
>   /usr/local/clang-trunk/bin/../include/c++/v1/__locale:961:34: error:
> too many arguments provided to function-like macro invocation
>    961 |     int length(state_type& __st, const extern_type* __frm,
> const extern_type* __end, size_t __mx) const
>        |                                  ^
>   /data/gannet/ripley/R/R-flang/include/Rinternals.h:968:9: note: macro
> 'length' defined here
>    968 | #define length(x)               Rf_length(x)
>
> For those R users who know C++ better than me, is there a standard way
> to avoid this?  I can think of a couple that should work (e.g. defining
> R_NO_REMAP globally, or rearranging the order of includes).  I'd like to
> use the standard one if there is such a thing.
>
> Duncan Murdoch
>
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel



More information about the R-package-devel mailing list