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

-----Ursprüngliche Nachricht-----
Von: R-package-devel <r-package-devel-boun...@r-project.org> Im Auftrag von 
Dirk Eddelbuettel
Gesendet: Sonntag, 1. Juni 2025 02:23
An: SN248 <sn...@cornell.edu>
Cc: List r-package-devel <r-package-devel@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 | e...@debian.org

______________________________________________
R-package-devel@r-project.org mailing list 
https://stat.ethz.ch/mailman/listinfo/r-package-devel

______________________________________________
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel

Reply via email to