Re: [R-pkg-devel] Canonical way to Rprintf R_xlen_t

2023-11-29 Thread Tomas Kalibera
On 11/29/23 19:30, Henrik Bengtsson wrote: On Tue, Nov 28, 2023 at 1:21 PM Tomas Kalibera wrote: On 11/28/23 21:50, Henrik Bengtsson wrote: Daniel, I get those compiler warnings for '%td" MS Windows. It works fine on Linux. Please let me clarify. %td works in R on Windows in R 4.3 and

Re: [R-pkg-devel] Canonical way to Rprintf R_xlen_t

2023-11-29 Thread Henrik Bengtsson
On Tue, Nov 28, 2023 at 1:21 PM Tomas Kalibera wrote: > > > On 11/28/23 21:50, Henrik Bengtsson wrote: > > Daniel, I get those compiler warnings for '%td" MS Windows. It works > > fine on Linux. > > Please let me clarify. %td works in R on Windows in R 4.3 and R-devel, > when using the

Re: [R-pkg-devel] Canonical way to Rprintf R_xlen_t

2023-11-28 Thread Tomas Kalibera
On 11/28/23 22:21, Tomas Kalibera wrote: On 11/28/23 21:50, Henrik Bengtsson wrote: Daniel, I get those compiler warnings for '%td" MS Windows. It works fine on Linux. Please let me clarify. %td works in R on Windows in R 4.3 and R-devel, when using the recommended toolchain, which is

Re: [R-pkg-devel] Canonical way to Rprintf R_xlen_t

2023-11-28 Thread Tomas Kalibera
On 11/28/23 21:55, Daniel Kelley wrote: I hope it's okay to ask this on the present thread, rather than starting a new one... On this issue of the C format for various integer-type items, I am finding that checks made with devtools::check_win_devel() give different results than those made

Re: [R-pkg-devel] Canonical way to Rprintf R_xlen_t

2023-11-28 Thread Tomas Kalibera
On 11/28/23 20:51, Ivan Krylov wrote: On Wed, 29 Nov 2023 06:11:23 +1100 Hugh Parsonage wrote: Rprintf("%lld", (long long) xlength(x)); This is fine. long longs are guaranteed to be at least 64 bits in size and are signed, just like lengths in R. Right, this has been my choice for R-devel,

Re: [R-pkg-devel] Canonical way to Rprintf R_xlen_t

2023-11-28 Thread Tomas Kalibera
On 11/28/23 21:50, Henrik Bengtsson wrote: Daniel, I get those compiler warnings for '%td" MS Windows. It works fine on Linux. Please let me clarify. %td works in R on Windows in R 4.3 and R-devel, when using the recommended toolchain, which is Rtools43. It also worked with R 4.2 and

Re: [R-pkg-devel] Canonical way to Rprintf R_xlen_t

2023-11-28 Thread Daniel Kelley
I hope it's okay to ask this on the present thread, rather than starting a new one... On this issue of the C format for various integer-type items, I am finding that checks made with devtools::check_win_devel() give different results than those made with the github R-CMD-check action named

Re: [R-pkg-devel] Canonical way to Rprintf R_xlen_t

2023-11-28 Thread Henrik Bengtsson
Daniel, I get those compiler warnings for '%td" MS Windows. It works fine on Linux. FYI, https://builder.r-hub.io/ is a great, free service for testing on various platforms in the cloud. Also, if you host your package code on GitHub, it's a small step to configure GitHub Actions to check your

Re: [R-pkg-devel] Canonical way to Rprintf R_xlen_t

2023-11-28 Thread Daniel Kelley
To HB: I also maintain a package that has this problem. I do not have access to a linux machine (or a machine with the C++ version in question) so I spent quite a while trying to get docker set up. That was a slow process because I had to install R, a bunch of packages, some other software,

Re: [R-pkg-devel] Canonical way to Rprintf R_xlen_t

2023-11-28 Thread Reed A. Cartwright
If I have read the R's change log correctly, C99 printf format is now supported on Windows. I think the change was made in the last week. On Tue, Nov 28, 2023, 13:01 Henrik Bengtsson wrote: > "%td" is not supported on all platforms/compilers. This is what I got > when I added it to

Re: [R-pkg-devel] Canonical way to Rprintf R_xlen_t

2023-11-28 Thread Henrik Bengtsson
"%td" is not supported on all platforms/compilers. This is what I got when I added it to 'matrixStats'; * using log directory 'D:/a/matrixStats/matrixStats/check/matrixStats.Rcheck' * using R Under development (unstable) (2023-11-26 r85638 ucrt) * using platform: x86_64-w64-mingw32 * R was

Re: [R-pkg-devel] Canonical way to Rprintf R_xlen_t

2023-11-28 Thread Ivan Krylov
On Wed, 29 Nov 2023 06:11:23 +1100 Hugh Parsonage wrote: > Rprintf("%lld", (long long) xlength(x)); This is fine. long longs are guaranteed to be at least 64 bits in size and are signed, just like lengths in R. > Rprintf("%td, xlength(x)); Maybe if you cast it to ptrdiff_t first. Otherwise I

Re: [R-pkg-devel] Canonical way to Rprintf R_xlen_t

2023-11-28 Thread Reed A. Cartwright
If you want to future proof your code, the first or third is the way to go. However, I prefer '%td' for readability. If R ever changes how R_xlen_t is defined, I assume the checks will alert me to the need to change the format string. On Tue, Nov 28, 2023, 12:12 Hugh Parsonage wrote: > Hello,

[R-pkg-devel] Canonical way to Rprintf R_xlen_t

2023-11-28 Thread Hugh Parsonage
Hello, I've been asked to update my package which contains numerous instances of Rprintf("%lld", xlength(x)); that is, erroneously using %lld for objects of type R_xlen_t. Having searched for the correct way, I seem to have come across 3 competing approaches: Rprintf("%lld", (long long)