[R-pkg-devel] How to handle CRAN warning regarding stdout/stderr coming from code in upstream C library
Dirk Eddelbuettel
edd @end|ng |rom deb|@n@org
Sun Jun 1 02:22:36 CEST 2025
On 31 May 2025 at 19:15, SN248 wrote:
| Dear R package developers
|
| I am getting the following errors in my package (sundialr -
| https://github.com/sn248/sundialr) which is a wrapper around SUNDIALS C
| library. The warnings are as follows:
|
| ❯ checking compiled code ...
| > WARNING File ‘sundialr/libs/sundialr.so’:
| > Found ‘abort’, possibly from ‘abort’ (C) Object:
| > ‘../inst/lib/libsundials_core.a’
| > Found ‘puts’, possibly from ‘printf’ (C), ‘puts’ (C) Object:
| > ‘../inst/lib/libsundials_core.a’
| > Found ‘stderr’, possibly from ‘stderr’ (C) Object:
| > ‘../inst/lib/libsundials_core.a’
| > Found ‘stdout’, possibly from ‘stdout’ (C) Objects:
| > ‘../inst/lib/libsundials_core.a’, ‘../inst/lib/libsundials_cvodes.a’,
| > ‘../inst/lib/libsundials_idas.a’, ‘../inst/lib/libsundials_nvecserial.a’
| > Compiled code should not call entry points which might terminate R nor
| > write to stdout/stderr instead of to the console, nor use Fortran I/O nor
| > system RNGs nor [v]sprintf. See ‘Writing portable packages’ in the ‘Writing
| > R Extensions’ manual.
|
|
| See them at -
| https://cran-archive.r-project.org/web/checks/2025/2025-05-12_check_results_sundialr.html
|
| As far as I understand these warnings are coming from the following files:
|
| 1. 'abort' coming from -
| https://github.com/sn248/sundialr/blob/ace6865ac0bc995190bc4c354a8823ea8d3bd358/src/sundials/sundials/sundials_errors.c#L87
You can get rid of `abort()` by using -DNDEBUG as a compiler flag.
| 2. I cannot find the file/line where 'puts' is coming from
You will have to locate it.
Bisection may help. It will likely be `(s(n))printf` as the message suggests.
| 3. stderr/stdout -- too many instances in SUNDIALS C code to list here,
| e.g.,
| https://github.com/sn248/sundialr/blob/ace6865ac0bc995190bc4c354a8823ea8d3bd358/src/sundials/arkode/arkode.c#L1285
|
| In principle, I don't want to change anything in the upstream C library
| code while including it in my package. Is this any other way to resolve
| these warnings as the package has been archived because of these warnings
| now.
There is no other way. You will have to change it in the code.
Small local patches, or more elaborate accommodation (as eg RcppArmadillo
does with Armadillo by having a way to inject Rcpp::Rcout).
Uploading to CRAN and getting its 'stamp of approval', and with it world-wide
distribution is still a privilege. It may cost a 'tax': most package
maintainers are willing to pay it while others complain and would rather not.
It's a choice, and it is yours to make. But the rules are made by CRAN.
Cheers, Dirk
--
dirk.eddelbuettel.com | @eddelbuettel | edd using debian.org
More information about the R-package-devel
mailing list