Skip to content

Cannot turn off checking of pragma(s) suppressing important diagnostics when including external headers #444

Closed
@carldelfin

Description

@carldelfin

I am developing an R package that uses JSON for Modern C++ (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 CMD check results ──────────────────── cppheader 0.0.0.9000 ────
Duration: 8.1schecking pragmas in C/C++ headers and code ... WARNING
  File which contains pragma(s) suppressing important diagnosticssrc/include/json.hpp

From what I can gather from Section 8 in R Internals, 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:

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:

══ 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_                            : FALSENOT_CRAN                                     : true

...

── R CMD check results ──────────────────── cppheader 0.0.0.9000 ────
Duration: 8.3schecking pragmas in C/C++ headers and code ... WARNING
  File which contains pragma(s) suppressing important diagnosticssrc/include/json.hpp

I raised this issue on Posit's forum, and was re-directed here; hope it's the right place.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions