Compilation of the following source file:
#include <Rcpp.h>
using namespace Rcpp;
/* this is a bug: http://bugbugbug.com */
// [[Rcpp::export]]
NumericVector timesTwo(NumericVector x) {
return x * 2;
}
Ends up with the following warning:
Warning message:
In Rcpp::sourceCpp("/tmp/test.cpp") :
No Rcpp::export attributes or RCPP_MODULE declarations found in source
Thanks for making R-C++ integration really seamless!
I guess a minimal reproducible buggy-comment is:
/* // */
What happens when you use
// this is a bug: http://bugbugbug.com
This only affects /**/ - style comments.
"Doctor, doctor, it hurts when I do this."
"Then don't do it."
We'll leave this open to remind us to make the regexp parser smarter. In the meantime, maybe stick to // comments when URLs with double forward slashes are embedded.
Jolly good.
It's a valid bug report, of course, but luckily not too many people have been bitten.
On a side note, I always wondered why
/* [[Rcpp::export]] */
is not a synonym for
// [[Rcpp::export]]
Maybe because the project is called Rcpp and not Rc ? ;-)
The parser in src/attributes is open source like the rest of it. If you have an itch to scratch, and can do it in a way that does not create side effects or regressions we might very well include it...
I haven't dug into this yet. But, I'm assuming that something is off with the regex specified src/attributes.cpp#L1141-L1142:
Or one of the other regex matches is picking it up....
"^\\s*//\\s*\\[\\[Rcpp::(\\w+)(\\(.*?\\))?\\]\\]\\s*$"
There may be dragons. Most of this is by @jjallaire , I would heed his sage advice as to what to try and not. Over the years we added a special treatment for a forgotten corner case here or there.
This one does not strike me as terribly important. It is a bug, yes. It should get fixed, yes.
But a million other things also compete for attention and this is, quite frankly, not that high up on my list.
I agree. I smudge but not one we should set aside the time to wipe away right now.
In the interim, add it to the known issues section per @thirdwing ?
BTW, it seems this issue has already been reported in #161
Tip: this can be fixed by adding a further comment with /* */ below, e.g.
#include <Rcpp.h>
using namespace Rcpp;
/* This will introduce a problem
https://github.com/RcppCore/Rcpp/issues/978 */
/* this fixes it */
// [[Rcpp::export]]
List rcpp_hello_world() {
CharacterVector x = CharacterVector::create( "foo", "bar" ) ;
NumericVector y = NumericVector::create( 0.0, 1.0 ) ;
List z = List::create( x, y ) ;
return z ;
}
This issue is stale (365 days without activity) and will be closed in 31 days unless new activity is seen. Please feel free to re-open it is still a concern, possibly with additional data.
Most helpful comment
Maybe because the project is called Rcpp and not Rc ? ;-)
The parser in src/attributes is open source like the rest of it. If you have an itch to scratch, and can do it in a way that does not create side effects or regressions we might very well include it...