Dear Rcpp folks,
could you please give me a hint on how to use `printf`. library(inline) inc <- " #include <stdio.h> " drucken <-cxxfunction(includes=inc, plugin="Rcpp", body=" unsigned int length = 1; printf("%u\\n", length); return wrap(length); ") throws the following error, when I try to source it. > source("/tmp/printf.r") Error in source("/tmp/printf.r") : /tmp/printf.r:8:11: unexpected input 7: unsigned int length = 1; 8: printf("%u\\n", length); Removing the `printf` statement gets rid of the error. I tested the standalone example and `gcc` does not complain. /* printf example */ #include <stdio.h> int main() { unsigned int length = 1; printf("%u \n", length); return length; } Probably my mistake is a simple one because > source("/usr/lib/R/site-library/Rcpp/examples/RcppInline/RcppInlineWithLibsExamples.r") works and `printf` statements are used in there. (I had to install `libgsl0-dev` to get the headers.) Thanks, Paul
/* printf example */ #include <stdio.h> int main() { unsigned int length = 1; printf("%u \n", length); return length; }
library(inline) inc <- " #include <stdio.h> " rw <-cxxfunction(includes=inc, plugin="Rcpp", body=" unsigned int length = 1; printf("%u\\n", length); return wrap(length); ")
signature.asc
Description: This is a digitally signed message part
_______________________________________________ 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