Package compilation fails when the package name contains a dot function and Rcpp

I am creating a new package:

  • The package name contains a period: for example, my.package
  • A package exports one Rcpp function: for example, rcppfunction

When I create a package using Rcmd INSTALL , compileAttributes used behind the scenes to automatically create the exported function,

 RcppExport SEXP my.package_rcppfunction(...) 

and I get a compilation error due to a dot in the exported name:

 RcppExports.cpp:10:19: error: expected initializer before '.' token 

As a workaround, I can change the name of the package to remove a point from it, but I want a better solution and understand how characters are exported. So my question is:

  • How can I parameterize the generated code to replace the dot with "_" for example (perhaps by specifying some parameters to the export attribute).
  • Or How to change the g ++ call to make it compile such dashed characters.

I don't know if this will help, but here is my g ++ call:

 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 
+6
source share
1 answer

You cannot do this - the dot is simply not resolved in the name of the C or C ++ function:

Those. for

 #include <stdlib.h> int foo.bar(int x) { return(2*x); } int main(void) { foo.bar(21); exit(0); } 

we get

 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$ 

and

 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$ 

In C ++, foo.bar() calls the member function bar() of the foo object.

+4
source

All Articles