Hi, I don't have access to a computer with R atm so I can't try. But the includes="#include <ctime>, #include <time.h>, #include <algorithm>. #include <vector>" 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? includes=c("#include <ctime>","#include <time.h>", "#include <algorithm>", "#include <vector>")
Sorry if I am completely off here. Like I said, can't try right now... Regards, Jonas On Thu, Sep 22, 2011 at 10:43 AM, Noah Silverman <noahsilver...@ucla.edu>wrote: > Hi, > > I have a vector of doubles that I want to sort. > > Using Rcpp and inline. When attempting to create the function, I receive > an error. Does anybody have any suggestions? > > =================== > Test <- cxxfunction( > signature(), > plugin="Rcpp", includes="#include <ctime>, #include <time.h>, > #include <algorithm>. #include <vector>", > body=" > std::vector<double> data; > > for(int i=0; i != 20; i++){ > data.push_back(i); > } > std::sort(data.front(), data.back()); > return Rcpp::wrap(data); > " > ) > > > Error in compileCode(f, code, language = language, verbose = verbose) : > 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>’: > /usr/include/c++/4.2.1/bits/stl_algo.h:2819: instantiated from ‘void > std::sort(_RandomAccessIterator, _RandomAccessIterator) [with > _RandomAccessIterator = double]’ > file6fb6ff92.cpp:36: instantiated from here > /usr/include/c++/4.2.1/bits/stl_iterator_base_types.h:129: error: ‘double’ > is not a class, struct, or union type > /usr/include/c++/4.2.1/bits/stl_iterator_base_types.h:130: error: ‘double’ > is not a class, struct, or union type > /usr/include/c++/4.2.1/bits/stl_iterator_base_types.h:131: error: ‘double’ > is not a class, struct, or union type > /usr/include/c++/4.2.1/bits/stl_iterator_base_types.h:132: error: ‘double’ > is not a class, struct, or union type > /usr/include/c++/4.2.1/bits/stl_iterator_base_types.h:133: error: ‘double’ > is not a class, struct, or union type > /usr/include/c++/4.2.1/b > In addition: Warning message: > running command '/Library/Frameworks/R.framework/Resources/bin/R CMD SHLIB > file6fb6ff92.cpp 2> file6fb6ff92.cpp.err.txt' had status 1 > > =========================== > -- > Noah Silverman > UCLA Department of Statistics > 8117 Math Sciences Building #8208 > Los Angeles, CA 90095 > > _______________________________________________ > Rcpp-devel mailing list > Rcpp-devel@lists.r-forge.r-project.org > https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel >
_______________________________________________ Rcpp-devel mailing list Rcpp-devel@lists.r-forge.r-project.org https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel