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">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/">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>