[Rcpp-devel] Using printf: Error in source("/tmp/printf.r") : /tmp/printf.r:8:11: unexpected input
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 -------------- next part -------------- A non-text attachment was scrubbed... Name: test.c Type: text/x-csrc Size: 138 bytes Desc: not available URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20111118/30deda5b/attachment.c> -------------- next part -------------- library(inline) inc <- " #include <stdio.h> " rw <-cxxfunction(includes=inc, plugin="Rcpp", body=" unsigned int length = 1; printf("%u\\n", length); return wrap(length); ") -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 198 bytes Desc: This is a digitally signed message part URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20111118/30deda5b/attachment.pgp>