[Rcpp-devel] Using Rcpp with C++11 and clang
Michael Braun
braunm at MIT.EDU
Tue Aug 28 20:46:55 CEST 2012
Is it possible that there is some kind of incompatibility among clang, libc++ and Rcpp? Consider this super-simple example (filename is tr1.cpp):
#include <Rcpp.h>
RcppExport SEXP testtr1() {
return(Rcpp::wrap(0));
}
If I compile it as a dynamic library with clang, I get:
clang -O3 -m64 -msse4.2 -std=c++11 -stdlib=libc++ -I/Library/Frameworks/R.framework/Headers -I/Library/Frameworks/R.framework/Resources/library/Rcpp/include -c tr1.cpp -o tr1.o
In file included from tr1.cpp:1:
In file included from /Library/Frameworks/R.framework/Resources/library/Rcpp/include/Rcpp.h:27:
/Library/Frameworks/R.framework/Resources/library/Rcpp/include/RcppCommon.h:143:10: fatal error: 'tr1/unordered_map' file not found
#include <tr1/unordered_map>
^
1 error generated.
This works fine with the Intel compiler, as well as with gcc version 4.6.1.
Looking at RcppCommon.h, I see that there are a number of checks, including the definition of HAS_TR!_UNORDERED_MAP. Is it possible that this code defines this macro for clang, when it shouldn't?
The version of clang I am using is:
Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin12.1.0
Thread model: posix
Rcpp is version 0.9.13. My OS is Mac OSX 10.8.1, and I have installed XCode 4.4.1, with the latest command line tools.
I see that this issue has been brought up in the past, but I have not been able to find a resolution. Since clang appears to be Apple's preferred compiler in XCode, I thought you might like to know about this, and perhaps let me know if I have made some kind of mistake.
Thanks,
-----------------------------------------------
Michael Braun
Associate Professor of Marketing
MIT Sloan School of Management
617-253-3436
braunm at mit.edu
http://braunm.scripts.mit.edu/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1583 bytes
Desc: not available
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20120828/566416ba/attachment.bin>
More information about the Rcpp-devel
mailing list