Cannot turn off `checking of pragma(s) suppressing important diagnostics` when including external headers
I am developing an R package that uses [JSON for Modern C++](https://github.com/nlohmann/json) (placed in `src/include/json.hpp` and included with `#include "include/json.hpp"`.) My issue is that `devtools::check()` warns about pragma(s) suppressing important diagnostics:
```r
── R CMD check results ──────────────────── cppheader 0.0.0.9000 ────
Duration: 8.1s
❯ checking pragmas in C/C++ headers and code ... WARNING
File which contains pragma(s) suppressing important diagnostics
‘src/include/json.hpp’
```
From what I can gather from Section 8 in [R Internals](https://rstudio.github.io/r-manuals/r-ints/Tools.html), this is controlled by the environment variable `_R_CHECK_PRAGMAS_`, which defaults to `FALSE` for non-CRAN checks but `TRUE` for CRAN checks.
I get the warning even though `NOT_CRAN` is `true` when testing locally. I also get the warning even when I explicitly set this environment variable to `FALSE`, and also set `NOT_CRAN` to `true`, like so:
```r
devtools::check(
document = TRUE,
env_vars = c(
"_R_CHECK_PRAGMAS_" = "FALSE",
"NOT_CRAN" = "true"
)
)
```
The environment variables are picked up, but I still get the warning:
```r
══ Checking════════════════════════════════════════════════
Setting env vars:
• _R_CHECK_CRAN_INCOMING_REMOTE_ : FALSE
• _R_CHECK_CRAN_INCOMING_ : FALSE
• _R_CHECK_FORCE_SUGGESTS_ : FALSE
• _R_CHECK_PACKAGES_USED_IGNORE_UNUSED_IMPORTS_: FALSE
• _R_CHECK_PRAGMAS_ : FALSE
• NOT_CRAN : true
```
...
```r
── R CMD check results ──────────────────── cppheader 0.0.0.9000 ────
Duration: 8.3s
❯ checking pragmas in C/C++ headers and code ... WARNING
File which contains pragma(s) suppressing important diagnostics
‘src/include/json.hpp’
```
I raised this issue on [Posit's forum](https://forum.posit.co/t/cannot-turn-off-checking-of-pragma-s-suppressing-important-diagnostics-when-including-external-c-headers/196934), and was re-directed here; hope it's the right place.
关闭于 2025-01-16 2 条评论