peter dalgaard <pdalgd <at> gmail.com> writes:
> C is call by value and k and res are pointers. You need a dereferencing
step or nothing with happen. Try
>
> *res = *k + 1;
Or you use Rcpp which writes the glue code. Save the following into a file:
#include <Rcpp.h>
// [[Rcpp::export]]
int adder(int x, int y) {
return x + y;
}
/*** R
adder(40, 2)
*/
Running this is as simple as sourcing it:
R> Rcpp::sourceCpp("/tmp/adder.cpp")
R> adder(40, 2)
[1] 42
R>
and it even runs the R snippet at the bottom.
Dirk
______________________________________________
[email protected] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.