Skip to content

Commit 7988986

Browse files
committed
undef TRUE/FALSE macros as needed
1 parent 7fcf9da commit 7988986

File tree

4 files changed

+48
-1
lines changed

4 files changed

+48
-1
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: RcppParallel
22
Type: Package
33
Title: Parallel Programming Tools for 'Rcpp'
4-
Version: 5.1.7-9000
4+
Version: 5.1.7-9001
55
Authors@R: c(
66
person("JJ", "Allaire", role = c("aut"), email = "[email protected]"),
77
person("Romain", "Francois", role = c("aut", "cph")),

inst/include/RcppParallel.h

+10
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,14 @@ inline void parallelReduce(std::size_t begin,
6969

7070
} // end namespace RcppParallel
7171

72+
// TRUE and FALSE macros that may come with system headers on some systems
73+
// But conflict with R.h (R_ext/Boolean.h)
74+
// TRUE and FALSE macros should be undef in RcppParallel.h
75+
#ifdef TRUE
76+
#undef TRUE
77+
#endif
78+
#ifdef FALSE
79+
#undef FALSE
80+
#endif
81+
7282
#endif // __RCPP_PARALLEL__

inst/tests/cpp/truefalse_macros.cpp

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @title Test for TRUE and FALSE macros
3+
* @author Travers Ching
4+
* @license GPL (>= 2)
5+
*/
6+
7+
// TRUE and FALSE macros that may come with system headers on some systems
8+
// But conflict with R.h (R_ext/Boolean.h)
9+
// TRUE and FALSE macros should be undef in RcppParallel.h
10+
11+
#include <Rcpp.h>
12+
#include <RcppParallel.h>
13+
14+
// [[Rcpp::depends(RcppParallel)]]
15+
16+
#ifndef TRUE
17+
static_assert(true, "Macro TRUE does not exist");
18+
#else
19+
static_assert(false, "Macro TRUE exists");
20+
#endif
21+
22+
#ifndef FALSE
23+
static_assert(true, "Macro FALSE does not exist");
24+
#else
25+
static_assert(false, "Macro FALSE exists");
26+
#endif
27+
28+
// [[Rcpp::export]]
29+
int hush_no_export_warning() {
30+
return 1;
31+
}

inst/tests/runit.truefalse_macros.R

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
library(Rcpp)
3+
library(RUnit)
4+
5+
sourceCpp(system.file("tests/cpp/truefalse_macros.cpp", package = "RcppParallel"))
6+

0 commit comments

Comments
 (0)