我正在构建一个新包:
当我使用构建包时Rcmd INSTALL,compileAttributes在场景后面使用自动生成导出函数,
RcppExport SEXP my.package_rcppfunction(...)
Run Code Online (Sandbox Code Playgroud)
由于导出名称中的点,我收到编译错误:
RcppExports.cpp:10:19: error: expected initializer before '.' token
Run Code Online (Sandbox Code Playgroud)
作为一种解决方法,我可以更改包名称以从中删除点,但我想要更好的解决方案并了解如何导出符号.所以我的问题是:
我不知道这是否有帮助,但这里是我的g ++调用:
g++ -m32 -I"PATH_TO_R/R-30~1.2/include" -DNDEBUG -
I"PATH_To_R/3.0/Rcpp/include" -
I"d:/RCompile/CRANpkg/extralibs64/local/include"
-O2 -Wall -mtune=core2 -c RcppExports.cpp -o RcppExports.o
Run Code Online (Sandbox Code Playgroud)
你不能这样做——C 或 C++ 函数名称中根本不允许使用点:
\n\n即对于
\n\n#include <stdlib.h>\n\nint foo.bar(int x) {\n return(2*x);\n}\n\nint main(void) {\n foo.bar(21);\n exit(0);\n}\nRun Code Online (Sandbox Code Playgroud)\n\n我们得到
\n\nedd@max:/tmp$ gcc -c foo.c\nfoo.c:4: error: expected \xe2\x80\x98=\xe2\x80\x99, \xe2\x80\x98,\xe2\x80\x99, \xe2\x80\x98;\xe2\x80\x99, \xe2\x80\x98asm\xe2\x80\x99 or \xe2\x80\x98__attribute__\xe2\x80\x99 before \xe2\x80\x98.\xe2\x80\x99 token\nfoo.c: In function \xe2\x80\x98main\xe2\x80\x99:\nfoo.c:9: error: \xe2\x80\x98foo\xe2\x80\x99 undeclared (first use in this function)\nfoo.c:9: error: (Each undeclared identifier is reported only once\nfoo.c:9: error: for each function it appears in.)\nedd@max:/tmp$ \nRun Code Online (Sandbox Code Playgroud)\n\n和
\n\nedd@max:/tmp$ g++ -c foo.c\nfoo.c:4: error: expected initializer before \xe2\x80\x98.\xe2\x80\x99 token\nfoo.c: In function \xe2\x80\x98int main()\xe2\x80\x99:\nfoo.c:9: error: \xe2\x80\x98foo\xe2\x80\x99 was not declared in this scope\nedd@max:/tmp$ \nRun Code Online (Sandbox Code Playgroud)\n\n在C++中, 就是调用对象的foo.bar()成员函数bar()foo。