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

Dirk Eddelbuettel edd at debian.org
Mon Nov 27 14:14:09 CET 2017


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.

|   Rcpp::Rcout << " rows are " << df1.size() << std::endl;
| }
| 
| ################
| 
| works fine.
| 
| Using clang (version 3.8 in a system with Debian, but I think same issues
| in Mac with clang 4) I get
| 
| 
| f5.cpp:12:19: error: conversion from 'NameProxy' (aka 'generic_name_proxy<19>') to 'Rcpp::DataFrame' (aka
|       'DataFrame_Impl<PreserveStorage>') is ambiguous
|   Rcpp::DataFrame df1 = bl["the_df"];
|                   ^     ~~~~~~~~~~~~
| /home/ramon/Sources/R-3.5.0-73698/library/Rcpp/include/Rcpp/vector/proxy.h:165:3: note: candidate function [with T =
|       Rcpp::DataFrame_Impl<PreserveStorage>]
|                 operator T() const {
|                 ^
| /home/ramon/Sources/R-3.5.0-73698/library/Rcpp/include/Rcpp/DataFrame.h:51:9: note: candidate constructor [with T =
|       Rcpp::internal::generic_name_proxy<19>]
|         DataFrame_Impl( const T& obj ) ;
|         ^
| 1 error generated.
| /home/ramon/Sources/R-3.5.0-73698/etc/Makeconf:166: recipe for target 'f5.o' failed
| make: *** [f5.o] Error 1
| Error in sourceCpp("f5.cpp", verbose = TRUE, rebuild = TRUE) :
|   Error 1 occurred building shared library.
| 
| 
| 
| Note that the following, treating the data frame as a list, works fine with
| both gcc and clang
| 
| 
| #include <Rcpp.h>
| using namespace Rcpp;
| 
| // [[Rcpp::export]]
| void withList(Rcpp::List bl) {
|   Rcpp::List df1 = bl["the_df"];
|   Rcpp::Rcout << " size is " << df1.size() << std::endl;
|   Rcpp::IntegerVector c1 = df1["first"];
|   Rcpp::Rcout << " rows are " << c1.size() << std::endl;
| }
| 
| 
| Is this bug?

I don't think so. See eg

https://github.com/eddelbuettel/rcppexamples/blob/master/src/ListExample.cpp

Dirk

| 
| Best,
| 
| 
| R.
| 
| --
| Ramon Diaz-Uriarte
| Department of Biochemistry, Lab B-25
| Facultad de Medicina
| Universidad Autónoma de Madrid
| Arzobispo Morcillo, 4
| 28029 Madrid
| Spain
| 
| Phone: +34-91-497-2412
| 
| Email: rdiaz02 at gmail.com
|        ramon.diaz at iib.uam.es
| 
| http://ligarto.org/rdiaz
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list