Hi,<br>I don't have access to a computer with R atm so I can't try. But the <br> includes="#include <ctime>, #include <time.h>, #include <algorithm>. #include <vector>"<br>looks fishy to me. First of all, note the dot before the last "include" instead of a comma. Secondly: wouldn't you need something like the below?<br>
includes=c("#include <ctime>","#include <time.h>", "#include <algorithm>", "#include <vector>")<br><br>Sorry if I am completely off here. Like I said, can't try right now...<br>
<br>Regards,<br>Jonas<br>
<br><div class="gmail_quote">On Thu, Sep 22, 2011 at 10:43 AM, Noah Silverman <span dir="ltr"><<a href="mailto:noahsilverman@ucla.edu">noahsilverman@ucla.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br>
<br>
I have a vector of doubles that I want to sort.<br>
<br>
Using Rcpp and inline. When attempting to create the function, I receive an error. Does anybody have any suggestions?<br>
<br>
===================<br>
Test <- cxxfunction(<br>
signature(),<br>
plugin="Rcpp", includes="#include <ctime>, #include <time.h>, #include <algorithm>. #include <vector>",<br>
body="<br>
std::vector<double> data;<br>
<br>
for(int i=0; i != 20; i++){<br>
data.push_back(i);<br>
}<br>
std::sort(data.front(), data.back());<br>
return Rcpp::wrap(data);<br>
"<br>
)<br>
<br>
<br>
Error in compileCode(f, code, language = language, verbose = verbose) :<br>
Compilation ERROR, function(s)/method(s) not created! /usr/include/c++/4.2.1/bits/stl_iterator_base_types.h: In instantiation of ‘std::iterator_traits<double>’:<br>
/usr/include/c++/4.2.1/bits/stl_algo.h:2819: instantiated from ‘void std::sort(_RandomAccessIterator, _RandomAccessIterator) [with _RandomAccessIterator = double]’<br>
file6fb6ff92.cpp:36: instantiated from here<br>
/usr/include/c++/4.2.1/bits/stl_iterator_base_types.h:129: error: ‘double’ is not a class, struct, or union type<br>
/usr/include/c++/4.2.1/bits/stl_iterator_base_types.h:130: error: ‘double’ is not a class, struct, or union type<br>
/usr/include/c++/4.2.1/bits/stl_iterator_base_types.h:131: error: ‘double’ is not a class, struct, or union type<br>
/usr/include/c++/4.2.1/bits/stl_iterator_base_types.h:132: error: ‘double’ is not a class, struct, or union type<br>
/usr/include/c++/4.2.1/bits/stl_iterator_base_types.h:133: error: ‘double’ is not a class, struct, or union type<br>
/usr/include/c++/4.2.1/b<br>
In addition: Warning message:<br>
running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB file6fb6ff92.cpp 2> file6fb6ff92.cpp.err.txt' had status 1<br>
<br>
===========================<br>
--<br>
Noah Silverman<br>
UCLA Department of Statistics<br>
8117 Math Sciences Building #8208<br>
Los Angeles, CA 90095<br>
<br>
_______________________________________________<br>
Rcpp-devel mailing list<br>
<a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">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>