Hi,

I’m currently working on a header-only library that it intended to act as a 
“glue" layer between an existing C++11 library (also header only) and R, by 
means of Rcpp.

Basically, I am trying to provide some generic templates that perform 
operations using the existing C++11 library and return appropriate data objects 
to the R environment.

My current plan for this library is that:

1. It is also c++11
2. It exists in its own namespace

Rcpp seems to have problems with the latter, but only on GCC.  I am unable to 
return XPtr to objects whose names are typedefs within a namespace.  However, 
everything works using clang++.

A reproducible example of this issue can be found at 
https://gist.github.com/molpopgen/989ec678664d083bf4a3 
<https://gist.github.com/molpopgen/989ec678664d083bf4a3>

Version numbers are:
Rcpp - 0.11.6
R - 3.1.0
g++ - 4.9.2
clang++ — 3.5 and 3.6
Ubuntu 14.04 LTS

I first discovered this when code I’d implemented on OS X/Yosemite/clang failed 
to link on my Linux box, where g++ is the default.

If you have git on your system and g++ as your default CXX, then

git clone https://gist.github.com/molpopgen/989ec678664d083bf4a3 
<https://gist.github.com/molpopgen/989ec678664d083bf4a3>
cd 989ec678664d083bf4a3
##This fails on my system with GCC w/no deleter for the XPtr found, but it 
compiles fine if I set ~/.R/Makevars to say CXX=clang++-3.6
Rscript doit.R
##This works with any of the compilers on my Ubunutu system, because I provide 
a custom deleter for the XPtr
Rscript doit2.R

If you look at the comments in the C++ code in the gist, this issue arises due 
to a strange mix of typedefs in a namespace + a template function in the same 
namespace.  However, I don’t think that this is an unusual use case.  Looking 
at the XPtr implementation, I don’t see any reason for the symbol not to be 
generated.

Thanks,

Kevin
_______________________________________________
Rcpp-devel mailing list
Rcpp-devel@lists.r-forge.r-project.org
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel

Reply via email to