Thanks, Dirk, as always for the quick response. It works, but I get an unusual compile error with the most recent RcppArmadillo (installed with install.packages this morning).
require(inline) require(Rcpp) require(RcppArmadillo) cppbugs.plugin <- getPlugin("RcppArmadillo") cppbugs.plugin$env$PKG_CXXFLAGS <- "-std=c++0x" foo <- cxxfunction(signature(hat="numeric"), body="return R_NilValue;",settings=cppbugs.plugin) results in: Error in compileCode(f, code, language = language, verbose = verbose) : Compilation ERROR, function(s)/method(s) not created! In file included from /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo_bits/Mat_meat.hpp:6091:0, from /usr/local/lib/R/site-library/RcppArmadillo/include/armadillo:369, from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadilloForward.h:36, from /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo.h:25, from file1724747be803.cpp:3: /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo/Mat_meat.h: In function ‘void arma::RcppArmadillo::check()’: /usr/local/lib/R/site-library/RcppArmadillo/include/RcppArmadillo/Mat_meat.h:34:5: error: expected ‘;’ before ‘}’ token make: *** [file1724747be803.o] Error 1 In addition: Warning message: running command '/usr/lib/R/bin/R CMD SHLIB file1724747be803.cpp 2> file1724747be803.cpp.err.txt' had status 1 Probably something I've overlooked. However, changing the 'cppbugs.plugin <- getPlugin("RcppArmadillo")' command to 'cppbugs.plugin <- getPlugin("Rcpp")' allows the example to compile. Is there a c++0x issue in the latest RcppArmadillo? I have: Version: 0.2.34 Date: $Date: 2011-12-12 16:56:37 -0600 (Mon, 12 Dec 2011) $ Anyway, I'll keep tinkering... -Whit On Tue, Jan 24, 2012 at 3:18 PM, Dirk Eddelbuettel <e...@debian.org> wrote: > > On 24 January 2012 at 14:46, Whit Armstrong wrote: > | using cxxfunction is there an easy (not using a custom plugin) way to > | add -std=c++0x to the g++ call? > > The best way, I think, is to call a plugin and to modify it. > > Quick example: > > > R> myplugin <- getPlugin("Rcpp") > R> myplugin$env$PKG_CXXFLAGS <- "-std=c++0x" > R> f <- cxxfunction(signature(), settings=myplugin, body=' > + std::vector<double> x = { 1.0, 2.0, 3.0 }; // fails without -std=c++0x > + return Rcpp::wrap(x); > + ') > R> f() > [1] 1 2 3 > R> > > > If you don't use the modified settings, it'll blow up as the 'curly init' is > a new feature: > > filebee52557bd2.cpp:32:44: error: in C++98 ‘x’ must be initialized by > constructor, not by ‘{...}’ > filebee52557bd2.cpp:32:44: error: could not convert ‘{1.0e+0, 2.0e+0, > 3.0e+0}’ from ‘<brace-enclosed initializer list>’ to ‘std::vector<double>’ > > but with the switch it all flies. > > I think I'll add that to the Rcpp-FAQ now. > > Note though that here I simply assigned PKG_CXXFLAGS which had been empty as > the Rcpp plugin does not set it. Other plugins may, so you one may have > append rather than overwrite. > > Dirk > > -- > "Outside of a dog, a book is a man's best friend. Inside of a dog, it is too > dark to read." -- Groucho Marx _______________________________________________ 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