Skip to content

undef TRUE and FALSE macros #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"))