-
-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error when passing arguments by reference #278
Comments
Thanks for the report -- confirmed under Ubuntu 14.10 with g++ 4.9.2. Removing the |
Also, it works with RcppArmadillo matrices: #include <RcppArmadillo.h>
// [[Rcpp::depends(RcppArmadillo)]]
// [[Rcpp::export]]
arma::mat test(const arma::mat & d){
return d;
} |
This is actually not a new bug (it's also in 0.11.3). This issue comes from the placement of the reference designator (&) next to the variable rather than the type. If you do this it will work: #include <Rcpp.h>
using namespace Rcpp;
// [[Rcpp::export]]
NumericMatrix test(const NumericMatrix & data){
return data;
} |
I have this problem still. The code reformatting of my IDE CLion (with its default settings) had moved the |
We are open to pull requests. We do not use CLion as an IDE so it is not exactly our problem... |
Evidence that everyone who binds Joking aside, this is genuinely a bug (I'm surprised nobody else has bumped into it thus far) but I would just ask CLion to change where it puts those tokens when reformatting. |
Just hit this after using clang-format (style=LLVM) which attaches the reference operator on the param name side. At first I thought WTF! Then after seeing the generated RcppExports.cpp a simple addition of |
Ohhhh now you're talking. Volunteering? ;-) |
We would of course carry the whole clang infrastructure with us, which ain't lightweight. RStudio has it (hi, @kevinushey) to parse for autocomplete and whatnot but we don't want to make behaviour of Rcpp depend on what IDE you use. |
I'm not sure what libclang does with comments (which is necessary for the |
I think clang's libformat (the backend of clang-format) gives access to the high level AST which , I'd guess, includes raw comments, and they can definitely be parsed (clang-format itself does this). But, I wasn't really serious. More like a brain murmer that made it to the keyboard. 😃 It would be fantastic though... |
One way to use libclang would be to search for it on the system and use it only when it's found. RStudio actually has a libclang wrapper which links dynamically at runtime rather than statically at build time so this wouldn't create a hard dependency on libclang (which we couldn't really do given CRAN). You can see how we do this here: https://github.com/rstudio/rstudio/blob/master/src/cpp/core/libclang/LibClang.cpp So we could have two parsing implementations, one of which works when libclang is installed and then the fallback which we have now. The main benefit of this would be the ability to handle namespaced types and typedefs as well as not ever running into problems like this one. |
I got compilation errors when I compiled the following code using
Rcpp::sourceCpp
.The error messages said,
Then, I checked
RcppExports.cpp
generated byRcpp::compileAttributes
, which was like as follows.It seems that the above code
should be
This problem did not occur in Rcpp(0.11.3)
Here is the information about my environment
Thank you.
The text was updated successfully, but these errors were encountered: