[Rd] 64-bit integer type warning on windows

Dirk Eddelbuettel edd at debian.org
Wed Mar 14 13:07:12 CET 2018


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



More information about the R-devel mailing list