Skip to content

Commit

Permalink
Merge pull request #211 from traversc/master
Browse files Browse the repository at this point in the history
undef TRUE and FALSE macros
  • Loading branch information
kevinushey authored Feb 28, 2024
2 parents 7fcf9da + 35b66ca commit 5aa08f8
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 2 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ name: R-CMD-check

jobs:
R-CMD-check:
runs-on: ubuntu-latest
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: windows-latest, r: 'release'}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: RcppParallel
Type: Package
Title: Parallel Programming Tools for 'Rcpp'
Version: 5.1.7-9000
Version: 5.1.7-9001
Authors@R: c(
person("JJ", "Allaire", role = c("aut"), email = "[email protected]"),
person("Romain", "Francois", role = c("aut", "cph")),
Expand Down
10 changes: 10 additions & 0 deletions inst/include/RcppParallel.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,14 @@ inline void parallelReduce(std::size_t begin,

} // end namespace RcppParallel

// TRUE and FALSE macros that may come with system headers on some systems
// But conflict with R.h (R_ext/Boolean.h)
// TRUE and FALSE macros should be undef in RcppParallel.h
#ifdef TRUE
#undef TRUE
#endif
#ifdef FALSE
#undef FALSE
#endif

#endif // __RCPP_PARALLEL__
31 changes: 31 additions & 0 deletions inst/tests/cpp/truefalse_macros.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* @title Test for TRUE and FALSE macros
* @author Travers Ching
* @license GPL (>= 2)
*/

// TRUE and FALSE macros that may come with system headers on some systems
// But conflict with R.h (R_ext/Boolean.h)
// TRUE and FALSE macros should be undef in RcppParallel.h

#include <Rcpp.h>
#include <RcppParallel.h>

// [[Rcpp::depends(RcppParallel)]]

#ifndef TRUE
static_assert(true, "Macro TRUE does not exist");
#else
static_assert(false, "Macro TRUE exists");
#endif

#ifndef FALSE
static_assert(true, "Macro FALSE does not exist");
#else
static_assert(false, "Macro FALSE exists");
#endif

// [[Rcpp::export]]
int hush_no_export_warning() {
return 1;
}
6 changes: 6 additions & 0 deletions inst/tests/runit.truefalse_macros.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

library(Rcpp)
library(RUnit)

sourceCpp(system.file("tests/cpp/truefalse_macros.cpp", package = "RcppParallel"))

0 comments on commit 5aa08f8

Please sign in to comment.