[Rd] Using long long types in C++

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Sep 20 08:39:30 CEST 2013


On 20/09/2013 03:04, Karl Millar wrote:
> Romain,
>
> Can you use int64_t and uint_t64 instead?  IMHO that would be more useful
> than long long anyway.

'Writing R Extensions' does say

'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 type such as int_fast64_t (and failing that, 
long long 42) and typedef your own type to be long or long long, or use 
another suitable type (such as size_t).

Note that int64_t is not portable, even in C99, since its implementation 
is optional.

On 20/09/2013 01:31, Patrick Welche wrote:
 >
 > Can you also add -std=c++0x or is that considered as bad as adding
 > -Wno-long-long?

That is not portable.  It is g++ specific and AFAIR not accepted by the 
version of g++ used on OS X (which dates from 2007).


>
> Karl
> On Sep 19, 2013 5:33 PM, "Patrick Welche" <prlw1 at cam.ac.uk> wrote:
>
>> On Fri, Sep 20, 2013 at 12:51:52AM +0200, romain at r-enthusiasts.com wrote:
>>> In Rcpp we'd like to do something useful for types such as long long
>>> and unsigned long long.
>> ...
>>> But apparently this is still not enough and on some versions of gcc
>>> (e.g. 4.7 something), -pedantic still generates the warnings unless
>>> we also use -Wno-long-long
>>
>> Can you also add -std=c++0x or is that considered as bad as adding
>> -Wno-long-long?
>>
>> (and why not use autoconf's AC_TYPE_LONG_LONG_INT and
>> AC_TYPE_UNSIGNED_LONG_LONG_INT for the tests?)
>>
>> Cheers,
>>
>> Patrick
>>
>> ______________________________________________
>> R-devel at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-devel
>>
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



More information about the R-devel mailing list