[Rcpp-devel] clang does not like lists with a DataFrame inside?

Dirk Eddelbuettel edd at debian.org
Tue Nov 28 00:24:33 CET 2017


On 28 November 2017 at 00:03, Ramon Diaz-Uriarte wrote:
| Hi Dirk,
| 
| 
| On Mon, 27-November-2017, at 14:14:09, Dirk Eddelbuettel <edd at debian.org> wrote:
| > Ramon,
| >
| > On 27 November 2017 at 10:43, Ramon Diaz-Uriarte wrote:
| > | Dear All,
| > |
| > | I am trying to pass to C++ an R list that contains a data frame. Using gcc
| > | the following
| > |
| > | #############################
| > |
| > | #include <Rcpp.h>
| > | using namespace Rcpp;
| > |
| > | // [[Rcpp::export]]
| > | void withDF(Rcpp::List bl) {
| > |   Rcpp::DataFrame df1 = bl["the_df"];
| >
| > I think every existing example uses a template when extracting items from a
| > list as we cannot know at compile time which run-time SEXP we will be handed.
| 
| Aha, understood. I did not think much about it, tried with gcc, it worked,
| and then was surprised to see it not work with clang.

These slight differences annoyed me at the beginning, but the advantage of
getting older is that you just get generally more forgetful.  "Just assume
nothing works unless you are explicit about it" seems to be my current motto :)

as<>() and wrap() are pretty magic.  We get by with fewer very explicit
statement than we used to years ago, but some remain, notably

  -- return statements better not be compound
  -- assignment from list or data.frame by name
  -- [ your issue here, space for rent upon request ]

[...]

| > I don't think so. See eg
| >
| > https://github.com/eddelbuettel/rcppexamples/blob/master/src/ListExample.cpp
| 
| Thanks for that. Bookmarked for future reference :-)

It's old and could be expanded but better than nothing.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list