[Rd] 64-bit integer type warning on windows
Christophe DUTANG
dutangc at gmail.com
Tue Mar 13 17:29:00 CET 2018
Dear list,
During the last two months, I spent a lot of time trying to remove the following warnings of my package randtoolbox:
congruRand.c:180:3: warning: ISO C does not support the 'I64' ms_scanf length modifier [-Wformat=]
sscanf(params[0], "%" PRIu64 "\n", &inp_mod);
Please see https://www.r-project.org/nosvn/R.check/r-devel-windows-ix86+x86_64/randtoolbox-00install.html
The warning is raised by the option -pedantic added when checking the package by R-devel. This warning is due to the use of the macro PRIu64. Note that this warning does not show up when I use PRIu64 with printf via Rprintf in other parts of the file congruRand.c.
My first reaction to look at https://msdn.microsoft.com/fr-fr/library/f9ezhzhs(v=vs.110).aspx is useless, because R on windows uses Mingw-W64 integer types and not the MS version.
Then, I tried to find information in such as Write Portable Code by Brian Hook and C11 (http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf).
They do recommend to use the macro SCNu64 (reserved for scanf family) rather than PRIu64 reserved for printf family functions.
Unfortunately when I check the package with R-devel, I still have the warning.
On GitHub, there are a version of mingw64 sources : https://github.com/Alexpux/mingw-w64/ . It is explicitly written that SCNu64 is I64u, see line 210 of https://github.com/Alexpux/mingw-w64/blob/master/mingw-w64-headers/crt/inttypes.h
So, I was wondering if this warning was removable at all? Does anyone encounter this issue?
Any help is appreciated.
Thanks in advance, Christophe
PS: latest version of randtoolbox source code is here https://r-forge.r-project.org/scm/viewvc.php/pkg/randtoolbox/?root=rmetrics
------------------------------------------------------------
Christophe Dutang
CEREMADE, Univ. Paris Dauphine, France
Web : http://dutangc.free.fr
More information about the R-devel
mailing list