[Rcpp-devel] correct way of making custom as and wrap functions available to other packages
Simon, Not sure if it'll help but take a look at https://github.com/Thell/RcppMultiPrecision/tree/wip-mpreal-wrappers Particularly the flags.R, inline.R and mpreal_wrap_example.cpp. When I built this Dirk pointed me to several example packages in the thread [Rcpp-devel] Rcpp RMpfr mpreal to mpfr wrapping. http://lists.r-forge.r-project.org/pipermail/rcpp-devel/2012-April/003719.html On Fri, Jul 17, 2015 at 10:12 AM, Simon Barthelm?
<simon.barthelme at gipsa-lab.fr> wrote:
Hi Kevin Thanks for your answer. I've tried declaring them as inline but the compiler (clang, haven't tried gcc) issues a warning saying it's going to ignore the inline statement. I'm assuming this is because the declaration is actually a template specialisation but I haven't found a definitive answer. If I separate the declaration from the definition, the linker now complains as and wrap are missing. Using the interface:: attribute doesn't seem to help either. Best Simon Le 17/07/2015 16:56, Kevin Thornton a ?crit : A good guess is that the as/wrap definitions in wrappers.h are the culprit (https://github.com/dahtah/imager/blob/master/inst/include/wrappers.h). Try declaring them as inline, or separating the definition from the declaration. ?Kevin On Jul 17, 2015, at 7:32 AM, Simon Barthelm? <simon.barthelme at gipsa-lab.fr> wrote: Dear list, For a package I'm developing (https://github.com/dahtah/imager/) I had to write custom "as" and "wrap" functions for third-party classes. I'd like to make these wrappers accessible to other developers via inline C++ as well as LinkingTo directives (so that they can be used in other packages). So far I've only managed the former: I have a header file in inst/include, called "wrappers.h", that contains the full implementations of my custom as and wrap functions. I've written a custom inline plugin and everything works fine. However, LinkingTo doesn't work: wrappers.h gets included in multiple object files and I get linking errors (the linker complains about multiple declarations of "as" and "wrap"). I understand RcppArmadillo manages to get around the problem but I can't figure out how. What's the correct way of doing this? Is there a way of making as and wrap inline functions so that it's safe to have header-only implementations? Thanks! Simon Barthelme
_______________________________________________ Rcpp-devel mailing list Rcpp-devel at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel _______________________________________________ Rcpp-devel mailing list Rcpp-devel at lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
Sincerely, Thell