<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    This has nothing to do with printf, this is simply because you use
    double quotes 'inside' double quotes, replace the outer quotes by
    single quotes and you should be fine. <br>
    <br>
    Please also note that Rprintf is preferred, because it will work on
    all platforms or user interfaces. <br>
    <br>
    Hope this helps, <br>
    <br>
    Romain<br>
    <br>
    <br>
    Le 18/11/11 20:32, Paul Menzel a &eacute;crit&nbsp;:
    <blockquote cite="mid:1321644728.3566.1.camel@mattotaupa"
      type="cite">
      <pre wrap="">Dear Rcpp folks,


could you please give me a hint on how to use `printf`.

        library(inline)
        inc &lt;- "
        #include &lt;stdio.h&gt;
        "
        
        drucken &lt;-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.

        &gt; 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 &lt;stdio.h&gt;
        
        int main()
        {
          unsigned int length = 1;
          printf("%u \n", length);
        
          return length;
        }

Probably my mistake is a simple one because 

</pre>
      <blockquote type="cite">
        <pre wrap="">source("/usr/lib/R/site-library/Rcpp/examples/RcppInline/RcppInlineWithLibsExamples.r")
</pre>
      </blockquote>
      <pre wrap="">
works and `printf` statements are used in there. (I had to install
`libgsl0-dev` to get the headers.)


Thanks,

Paul
</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Rcpp-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a>
<a class="moz-txt-link-freetext" href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a></pre>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Romain Francois
Professional R Enthusiast
<a class="moz-txt-link-freetext" href="http://romainfrancois.blog.free.fr">http://romainfrancois.blog.free.fr</a></pre>
  </body>
</html>