r-lib / later

Schedule an R function or formula to run after a specified period of time.
https://r-lib.github.io/later
Other
137 stars 27 forks source link

cpp11 support #143

Closed nx10 closed 3 years ago

nx10 commented 3 years ago

I am currently migrating a package from Rcpp to cpp11 and was wondering if cpp11 support was planned for later?

I am only including later from C++ and it seems Rcpp is only used for including /Rinternals.h. I was able to work around that by creating a file with the name /Rcpp.h which looks like this:

#pragma once
#import <cpp11/R.hpp>

this seems to work without issue so far, but is of course a bit "hacky". I know Rcpp is used in the R interface, but a compiler flag similar to this would be great:

// later.h
// ...
#ifdnef LATER_CPP11
#include <Rcpp.h>
#else
#include <cpp11/R.h>
#endif
// ...

Alternatively the R headers could be included without Rcpp:

#define R_NO_REMAP
#define STRICT_R_HEADERS
#include "Rinternals.h"
wch commented 3 years ago

Yes, we're planning on making later work with packages that don't want to include Rcpp.

I think that including Rinternals.h may be the way to go.