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
Juan Telleria Ruiz de Aguirre
2018-Mar-14 11:34 UTC
[Rd] 64-bit integer type warning on windows
It does not answer direcly your question, but have you tried "bit64" CRAN package :) https://cran.r-project.org/web/packages/bit64/index.html
On 13 March 2018 at 17:29, Christophe DUTANG wrote: | So, I was wondering if this warning was removable at all? Does anyone encounter this issue? That is a pretty old topic. Did you look into Writing R Extensions? The first mention is * Do be very careful with passing arguments between R, C and FORTRAN code. In particular, 'long' in C will be 32-bit on some R platforms (including 64-bit Windows), but 64-bit on most modern Unix and Linux platforms. It is rather unlikely that the use of 'long' in C code has been thought through: if you need a longer type than 'int' you should use a configure test for a C99/C++11 type such as 'int_fast64_t' (and failing that, 'long long' (8)) and typedef your own type to be 'long' or 'long long', or use another suitable type (such as 'size_t'). It is not safe to assume that 'long' and pointer types are the same size, and they are not on 64-bit Windows. If you need to convert pointers to and from integers use the C99/C++11 integer types 'intptr_t' and 'uintptr_t' (which are defined in the header '<stdint.h>' and are not required to be implemented by the C99 standard but are used in C code by R itself). Note that 'integer' in FORTRAN corresponds to 'int' in C on all R platforms. [...] (8) but note that 'long long' is not a standard C++98 type, and C++ compilers set up for strict checking will reject it. so with C++11 you get by: simply make your package use 'CXX_STD = CXX11'. Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org