我使用 Rcpp 制作了一个简单的 R 包,但是当我设置时 系统要求:C++20 关于描述,我在构建时遇到以下错误。
clang++ -arch x86_64 -std=gnu++20 -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I'/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include' -I/opt/R/x86_64/include -fPIC -falign-functions=64 -Wall -g -O2 -UNDEBUG -Wall -pedantic -g -O0 -c RcppExports.cpp -o RcppExports.o
In file included from RcppExports.cpp:4:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/Rcpp.h:78:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/Rcpp/sugar/sugar.h:31:
In file included from /Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/Rcpp/sugar/functions/functions.h:42:
/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/Rcpp/sugar/functions/sapply.h:36:19: error: no template named 'result_of' in namespace 'std'; did you mean 'traits::result_of'?
typedef typename ::std::result_of<Function(typename SugarExpression::stored_type)>::type type;
^~~~~~~~~~~~~~~~
traits::result_of
/Library/Frameworks/R.framework/Versions/4.3-x86_64/Resources/library/Rcpp/include/Rcpp/traits/result_of.h:30:8: note: 'traits::result_of' declared here
struct result_of{
^
1 error generated.
make: *** [RcppExports.o] Error 1
ERROR: compilation failed for package
是否可以使用 C++20 构建包?
最佳答案
最后一次 Rcpp 版本(版本 1.0.10)发生在 1 月份。但是使用 clang++
支持 C++20 所需的代码是在二月份添加的,参见https://github.com/RcppCore/Rcpp/pull/1248 。您可以从项目 drat
存储库获取中间版本:
install.packages("Rcpp", repos="https://RcppCore.github.io/drat")
未经测试,因为您没有提供最小的示例。
关于rcpp - 使用 Rcpp 和 C++20 的 R 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76454448/