Skip to content

Commit 64694cf

Browse files
committed
Define RCPP_NO_R_HEADERS_CHECK before all #include <Rcpp.h> usage
`#include <cpp11/R.hpp>` sets everything up the right way, and otherwise we get a warning from Rcpp which doesn't seem to end up being relevant for this use case
1 parent 6744a81 commit 64694cf

File tree

7 files changed

+16
-4
lines changed

7 files changed

+16
-4
lines changed

R/register.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,13 @@ cpp_register <- function(path = ".", quiet = !is_interactive(), extension = c(".
8989

9090
extra_includes <- character()
9191
if (pkg_links_to_rcpp(path)) {
92-
extra_includes <- c(extra_includes, "#include <cpp11/R.hpp>", "#include <Rcpp.h>", "using namespace Rcpp;")
92+
extra_includes <- c(
93+
extra_includes,
94+
"#include <cpp11/R.hpp>",
95+
"#define RCPP_NO_R_HEADERS_CHECK",
96+
"#include <Rcpp.h>",
97+
"using namespace Rcpp;"
98+
)
9399
}
94100

95101
pkg_types <- c(

cpp11test/src/cpp11.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// clang-format off
33

44
#include <cpp11/R.hpp>
5+
#define RCPP_NO_R_HEADERS_CHECK
56
#include <Rcpp.h>
67
using namespace Rcpp;
78
#include "cpp11/declarations.hpp"

cpp11test/src/find-intervals.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include "cpp11.hpp"
33
using namespace cpp11;
44

5+
#define RCPP_NO_R_HEADERS_CHECK
56
#include <Rcpp.h>
67
#include <algorithm>
78
using namespace Rcpp;

cpp11test/src/matrix.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ using namespace cpp11;
3232
return mat;
3333
}
3434

35+
#define RCPP_NO_R_HEADERS_CHECK
3536
#include <Rcpp.h>
3637
using namespace Rcpp;
3738

cpp11test/src/protect.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#include <cpp11/sexp.hpp>
22
#include <vector>
33

4-
#include "Rcpp.h"
4+
#define RCPP_NO_R_HEADERS_CHECK
5+
#include <Rcpp.h>
56

67
[[cpp11::register]] void protect_one_(SEXP x, int n) {
78
for (R_xlen_t i = 0; i < n; ++i) {

cpp11test/src/release.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#include <vector>
22
#include "cpp11/sexp.hpp"
33

4-
#include "Rcpp.h"
4+
#define RCPP_NO_R_HEADERS_CHECK
5+
#include <Rcpp.h>
56

67
[[cpp11::register]] void cpp11_release_(int n) {
78
std::vector<cpp11::sexp> x;

cpp11test/src/test-as.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77

88
#include <testthat.h>
99

10-
#include "Rcpp.h"
10+
#define RCPP_NO_R_HEADERS_CHECK
11+
#include <Rcpp.h>
1112

1213
context("as_cpp-C++") {
1314
test_that("as_cpp<integer>(INTSEXP)") {

0 commit comments

Comments
 (0)