我正在构建一个新包:
当我使用Rcmd INSTALL
构建包时,在场景后面使用compileAttributes
来自动生成导出的函数,
RcppExport SEXP my.package_rcppfunction(...)
由于导出名称中的点而导致编译错误:
RcppExports.cpp:10:19: error: expected initializer before '.' token
作为一种解决方法,我可以更改包名称以从中删除点,但我想要更好的解决方案并了解符号的导出方式。所以我的问题是:
我不知道这是否有帮助,但这里是我的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
答案 0 :(得分:4)
你不能这样做 - 在C或C ++函数名中不允许使用点:
即
#include <stdlib.h>
int foo.bar(int x) {
return(2*x);
}
int main(void) {
foo.bar(21);
exit(0);
}
我们得到了
edd@max:/tmp$ gcc -c foo.c
foo.c:4: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘.’ token
foo.c: In function ‘main’:
foo.c:9: error: ‘foo’ undeclared (first use in this function)
foo.c:9: error: (Each undeclared identifier is reported only once
foo.c:9: error: for each function it appears in.)
edd@max:/tmp$
和
edd@max:/tmp$ g++ -c foo.c
foo.c:4: error: expected initializer before ‘.’ token
foo.c: In function ‘int main()’:
foo.c:9: error: ‘foo’ was not declared in this scope
edd@max:/tmp$
在C ++中,foo.bar()
正在调用对象bar()
的成员函数foo
。