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

Reed A. Cartwright r@c@rtwr|ght @end|ng |rom gm@||@com
Tue Nov 28 20:28:37 CET 2023


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 <hugh.parsonage using gmail.com> wrote:

> 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) xlength(x));
> Rprintf("%td, xlength(x));
> or
> using the string macro found in Mr Kalibera's commit of r85641:
> R_PRIdXLEN_T
>
> Which would be most advisable for my update, required in the next
> fortnight?
>
>
> Hugh Parsonage
>
> ______________________________________________
> R-package-devel using r-project.org mailing list
>
> https://urldefense.com/v3/__https://stat.ethz.ch/mailman/listinfo/r-package-devel__;!!IKRxdwAv5BmarQ!Z8-N4e22USctsG9tcHzIQD68xn2kfOxHbsIkktS-KaUNastoH7N_u-Rcd7A334uZhvRptIIDwDWKTXqgS8lSCAPOTA$
>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list