[Rcpp-devel] 64-bit ints on Windows 64-bit via size_t, unsigned long long, or unsigned __int64

Dirk Eddelbuettel edd at debian.org
Wed Jul 11 22:18:31 CEST 2012


Further follow-up, quoting from 'Writing R Extensions':

-----------------------------------------------------------------------------
1.7 Writing portable packages
=============================

[...]
   * Do be very careful with passing arguments between R, C and FORTRAN
     code.  In particular, `long' in C will be 32-bit on most R
     platforms (including those mostly used by the CRAN maintainers),
     but 64-bit on many 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 type such as `int_fast64_t' (and failing
     that, `long long' (2)) 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 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).

     Note that `integer' in FORTRAN corresponds to `int' in C on all R
     platforms.

[...]

   (2) but note that `long long' is not a standard C++ type, and C++
compilers set up for strict checking will reject it.
-----------------------------------------------------------------------------


So until CRAN considers C++11 a working standard (and all recent compilers
can support it) we will not have 'long long' in C++.

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com  


More information about the Rcpp-devel mailing list