Hi Kevin,<br><br>Great! . Problem fixed now. Thanks a lot. <br><br>Regards<br>Bharath<br><br><br><div class="gmail_quote">On Thu, Feb 14, 2013 at 2:33 AM, Kevin Ushey <span dir="ltr"><<a href="mailto:kevinushey@gmail.com" target="_blank">kevinushey@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Could it be because the file extension is .c rather than the expected .cpp? Compiling the code runs fine for me when the file extension is .cpp, but I get the same errors as you with the file extension as .c .<div>
<br></div>
<div>-Kevin<br><br><div class="gmail_quote"><div><div class="h5">On Wed, Feb 13, 2013 at 11:15 PM, Bharath Govindarajan <span dir="ltr"><<a href="mailto:bharath.quant@gmail.com" target="_blank">bharath.quant@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5">Hi,<br><br>At the outset I would like to thank the developers of rcpp for this wonderful tool. My question <br>
is elementary but I am posting it here only because on stack exchange I see Dirk suggesting that <br>
this is a better place to get replies. <br>
<br>Thanks again <br>Bharath<br><br><br><br>Places I searched so far :<br>-------------------------------------<br>google , stack exchange :<br>" rcpp compilation error __attribute__ "<br>" rcpp Reference.h:25 error"<br>
" rcpp asm error"<br><br><br><br>> version<br> _ <br>platform x86_64-unknown-linux-gnu <br>arch x86_64 <br>os linux-gnu <br>
system x86_64, linux-gnu <br>status <br>major 2 <br>minor 15.1 <br>year 2012 <br>
month 06 <br>day 22 <br>svn rev 59600 <br>language R <br>version.string R version 2.15.1 (2012-06-22)<br>
nickname Roasted Marshmallows <br><br>Description of problem:<br>--------------------------------<br>I tried a very simple example from Hadley Wickham's website and it worked <br><a href="https://github.com/hadley/devtools/wiki/Rcpp" target="_blank">https://github.com/hadley/devtools/wiki/Rcpp</a><br>
<br>cppFunction('<br> double sumC(NumericVector x) {<br> int n = x.size();<br> double total = 0;<br> for(int i = 0; i < n; ++i) {<br> total += x[i];<br> }<br> return total;<br> }<br>')<br>
<br>Then I try an example written in a c source file from <a href="http://dirk.eddelbuettel.com/blog/2012/11/14/" target="_blank">http://dirk.eddelbuettel.com/blog/2012/11/14/</a><br> and source it and get compilation errors<br>
<br>test1.c<br>
------<br>#include <Rcpp.h><br><br>// [[Rcpp::export]]<br>Rcpp::DataFrame mypnorm(Rcpp::NumericVector x) {<br> int n = x.size();<br> Rcpp::NumericVector y1(n), y2(n), y3(n);<br><br> for (int i=0; i<n; i++) {<br>
<br> // the way we used to do this<br> y1[i] = ::Rf_pnorm5(x[i], 0.0, 1.0, 1, 0);<br><br> // the way we can do it now<br> y2[i] = R::pnorm(x[i], 0.0, 1.0, 1, 0);<br><br> }<br> // or using Rcpp sugar in one go<br>
y3 = Rcpp::pnorm(x);<br><br> return Rcpp::DataFrame::create(Rcpp::Named("Rold") = y1,<br> Rcpp::Named("Rnew") = y2,<br> Rcpp::Named("sugar") = y3);<br>
}<br><br>commands:<br>---------<br>sourceCpp(LIB.PATH %+% "test1.c",verbose=TRUE)<br><br>Error:<br>------<br><br>R/x86_64-unknown-linux-gnu-library/2.15/Rcpp/include/Rcpp/internal/wrap_end.h:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Rcpp'<br>
In file included from R/x86_64-unknown-linux-gnu-library/2.15/Rcpp/include/Rcpp/api/meat/meat.h:25,<br> from R/x86_64-unknown-linux-gnu-library/2.15/Rcpp/include/Rcpp.h:81,<br> from test1.c:1:<br>
R/x86_64-unknown-linux-gnu-library/2.15/Rcpp/include/Rcpp/api/meat/RObject.h:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Rcpp'<br>In file included from R/x86_64-unknown-linux-gnu-library/2.15/Rcpp/include/Rcpp/api/meat/meat.h:26,<br>
from R/x86_64-unknown-linux-gnu-library/2.15/Rcpp/include/Rcpp.h:81,<br> from test1.c:1:<br>R/x86_64-unknown-linux-gnu-library/2.15/Rcpp/include/Rcpp/api/meat/Environment.h:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Rcpp'<br>
In file included from R/x86_64-unknown-linux-gnu-library/2.15/Rcpp/include/Rcpp/api/meat/meat.h:27,<br> from R/x86_64-unknown-linux-gnu-library/2.15/Rcpp/include/Rcpp.h:81,<br> from test1.c:1:<br>
R/x86_64-unknown-linux-gnu-library/2.15/Rcpp/include/Rcpp/api/meat/DottedPair.h:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Rcpp'<br>In file included from R/x86_64-unknown-linux-gnu-library/2.15/Rcpp/include/Rcpp/api/meat/meat.h:28,<br>
from R/x86_64-unknown-linux-gnu-library/2.15/Rcpp/include/Rcpp.h:81,<br> from test1.c:1:<br>R/x86_64-unknown-linux-gnu-library/2.15/Rcpp/include/Rcpp/api/meat/Vector.h:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Rcpp'<br>
In file included from R/x86_64-unknown-linux-gnu-library/2.15/Rcpp/include/Rcpp/api/meat/meat.h:29,<br> from R/x86_64-unknown-linux-gnu-library/2.15/Rcpp/include/Rcpp.h:81,<br> from test1.c:1:<br>
R/x86_64-unknown-linux-gnu-library/2.15/Rcpp/include/Rcpp/api/meat/Matrix.h:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Rcpp'<br>In file included from R/x86_64-unknown-linux-gnu-library/2.15/Rcpp/include/Rcpp/api/meat/meat.h:30,<br>
from R/x86_64-unknown-linux-gnu-library/2.15/Rcpp/include/Rcpp.h:81,<br> from test1.c:1:<br>R/x86_64-unknown-linux-gnu-library/2.15/Rcpp/include/Rcpp/api/meat/Reference.h:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Rcpp'<br>
test1.c:4: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token<br>test1.c:28: error: expected identifier or '(' before string constant<br>make: *** [test1.o] Error 1<br>
Error in sourceCpp(LIB.PATH %+% "test1.c", verbose = TRUE) : <br> Error 1 occurred building shared library.<br><br><br>
<br></div></div>_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br></blockquote></div><br></div>
</blockquote></div><br>