Skip to content
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

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

Closed
carldelfin opened this issue Jan 16, 2025 · 2 comments

Comments

@carldelfin
Copy link

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.

@DavisVaughan
Copy link
Member

CRAN / R CMD check warns about any #pragmas included in your package. Yours seem to come from json.hpp here:

https://github.com/nlohmann/json/blob/ad2ee18539aa53df0908ada2a075d381a55138d8/include/nlohmann/json.hpp#L774

That doesn't have anything to do with cpp11 FWIW, so there is nothing for us to do on our end.

The "right" thing to do (even though it stinks) is to go in and hand modify json.hpp to remove those pragmas if possible. But there are 9 of them and that sounds super annoying for you. You didn't hear it from me, but you can probably change them from #pragma to # pragma (note the space) and that might turn the warning off...

@carldelfin
Copy link
Author

Thanks a lot for the quick reply - a swift %s/#pragma/# pragma/ may or may not have resolved the issue...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants