[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 16:22:50 CEST 2025
On 1 June 2025 at 15:17, matthias-gondan using gmx.de wrote:
| Dirk, can you elaborate this a bit:
|
| > as eg RcppArmadillo does with Armadillo by having a way to inject Rcpp::Rcout
|
| Might be useful elsewhere
See the source and ChangeLog for the (brief) details. In essence, a little
arm-twisting by us convinced Conrad upstream to have his stdout use be under
a preprocessor macro which, when building for R, injects Rcpp::Rcout (and
idem for Rcerr). See the code at
https://github.com/RcppCore/RcppArmadillo/blob/master/inst/include/RcppArmadillo/config/RcppArmadilloConfig.h#L76-L87
which (in essence) defines two identifiers with R's output sinks. By
including our headers before the upstream ones this is now defined, and then
used.
"Works great" and has been for thirteen years (!!) per my ChangeLog with an
occassional rename in-between. Used by over 1200 (!!) reverse-dependencies
too without them having to do anything. We actually do something similar for
the (main U(0,1)) RNG (but not N(0,1) as Armadillo has its own, longer story,
so keep using R's N(0,1)).
Hth, Dirk
| -----Ursprüngliche Nachricht-----
| Von: R-package-devel <r-package-devel-bounces using r-project.org> Im Auftrag von Dirk Eddelbuettel
| Gesendet: Sonntag, 1. Juni 2025 02:23
| An: SN248 <sn248 using cornell.edu>
| Cc: List r-package-devel <r-package-devel using r-project.org>
| Betreff: Re: [R-pkg-devel] How to handle CRAN warning regarding stdout/stderr coming from code in upstream C library
|
|
| 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_re
| | sults_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/ace6865ac0bc995190bc4c354a8823e
| | a8d3bd358/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/ace6865ac0bc995190bc4c354a8823e
| | a8d3bd358/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
|
| ______________________________________________
| R-package-devel using r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel
|
--
dirk.eddelbuettel.com | @eddelbuettel | edd using debian.org
More information about the R-package-devel
mailing list