On 18 October 2013 at 22:13, Mark Fredrickson wrote: | Short version: Is it possible to instruct the code generator in | `compileAttributes` to source local header files when generating | RcppExports.cpp?
I'll let JJ take the Attributes aspect but maybe it is something else... | Long version: I'm trying to crib from the Dirk's examples in his recent UCB [ Nit: U of C, not UCB. If UCB wants to invite me ... ;-) ] | talk examples about function pointers (http://dirk.eddelbuettel.com/papers/ | rcpp_booth_uofc_oct2013-part2.pdf). In it, he uses a `typedef` to define the | type of his function call. This is all great if using `sourceCpp` to slurp in | the file directly, but I'm getting errors when compiling a package. I'd like to | use attributes to export my functions at both the R level and as the target of | function pointers, but this may be incompatible with attributes, at least at | some level. The same trick was already used in RcppDE (which was a proof of concept about converting DEoption from 700 lines of plain C to 400 lines of C++ / Rcpp) where I have typedef double (*funcPtr)(SEXP); and the rest works like a 'plain old package'. | My (perhaps naive) attempts are giving errors about my `funcPtr` type not being | defined. I've tried moving this definition to a header file, but even with `// | [[Rcpp::depends(myheader)]]` or `\\[Rcpp::depends(myheader.h)]]`, the generated | RcppExports.cpp file does not include `myheader.h`. What exactly is the error? Could it be as simple as missing -I. in src/Makevars ? That is not added by default so try adding the line PKG_CPPFLAGS = -I. (not indented, of course) to src/Makevars (and src/Makevars.win) | My (non-working) code can be found at: | | https://github.com/markmfredrickson/RItools/blob/ri-rcpp/src/teststatistics.cpp Thanks for the pointer to sources. Hope this helps, Dirk -- Dirk Eddelbuettel | e...@debian.org | http://dirk.eddelbuettel.com _______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel