arrow-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aldrin <>
Subject Re: Understanding R and C++ using cpp11
Date Thu, 17 Jun 2021 15:57:40 GMT
An update:

I have organized my code like an R package (after reading more about
NAMESPACE file), and I used `devtools::document()` to generate source files
(per cpp11 docs <>).
Unfortunately, the generated source does not propagate my include
directives, which seems to make clear why using `cpp_source` does not work
for my code. Here is a code excerpt of what is generated:

// skytethr.cpp
arrow::Result<BatchStreamRdrPtr> R_GetReaderForKey(cpp11::r_string
extern "C" SEXP _skytethr_R_GetReaderForKey(SEXP table_key) {

I manually added the include of arrow to the generated source to see if
that is my only problem, but I get many errors related to the return value
being wrapped in `cpp11::as_sexp`.

To continue my proof-of-concept, I can change my C++ code to return a
simpler type (just an arrow table, maybe), but I think I ultimately will
need to figure out how to return a type that is defined by the `arrow`
package. Other than doing a short-term copy-paste of headers, is there a
recommended path forward on how to return a type that R knows about from
the `arrow` package? My first thought is that maybe I can import some
variables from the arrow namespace in my namespace file
maybe in the essence of this example

Thanks for any help or feedback!

Aldrin Montana
Computer Science PhD Student
UC Santa Cruz

On Tue, Jun 8, 2021 at 8:54 AM Aldrin <> wrote:

> Thank you Neal! I'll check those out and I appreciate the tips!
> Hi Antoine, I do include those. That's a reason I am especially confused,
> since I don't get any issue on including them. Although, interestingly, the
> error " 'arrow' does not name a type " is there whether or not I include
> the arrow headers. If they are not included though, compilation stops at
> that step.
> Here's a gist to make it easier to see the difference. I've also included
> more code just for completeness. If there's anything else I can include
> that would be helpful, please let me know!
> Aldrin Montana
> Computer Science PhD Student
> UC Santa Cruz
> On Tue, Jun 8, 2021 at 12:14 AM Antoine Pitrou <> wrote:
>> On Fri, 4 Jun 2021 17:26:03 -0700
>> Aldrin <> wrote:
>> > Hello!
>> >
>> > I am trying to wrap some C++ code I have that uses arrow with R to
>> enable
>> > users to continue working in R. Unfortunately, I get a compilation
>> error of
>> > `arrow does not name a type` when it gets to the return type of my
>> function
>> > which is
>> > `arrow::Result<std::shared_ptr<arrow::ipc::RecordBatchStreamReader>>`.
>> > posted in RStudio in case this is purely a cpp11 library issue
>> happening (
>> >
>> Did you include the Arrow headers? For example `#include "arrow/api.h"`?

View raw message