|
22 | 22 | #ifndef RCPP_LONG_LONG_H
|
23 | 23 | #define RCPP_LONG_LONG_H
|
24 | 24 |
|
25 |
| -// 'long long' is a C99 extension and (as of fall 2013) still |
26 |
| -// forbidden by CRAN which stick with the C++98 standard predating it. |
27 |
| -// One way to get 'long long' is to switch to C++11, another is to use |
28 |
| -// clang++ from the llvm project. |
29 |
| -#ifdef __GNUC__ |
30 |
| -#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined (__clang__) && defined(__LP64__)) |
31 |
| - |
32 |
| -#if defined(__GNUC__) && defined(__LONG_LONG_MAX__) |
| 25 | +// long long is explicitly available to C++11 (and above) compilers |
| 26 | +#if __cplusplus >= 201103L |
| 27 | + |
| 28 | +typedef long long int rcpp_long_long_type; |
| 29 | +typedef unsigned long long int rcpp_ulong_long_type; |
| 30 | +# define RCPP_HAS_LONG_LONG_TYPES |
| 31 | + |
| 32 | +// GNU compilers may make 'long long' available as an extension |
| 33 | +// (note that __GNUC__ also implies clang, MinGW) |
| 34 | +#elif defined(__GNUC__) |
| 35 | + |
| 36 | +// check to see if 'long long' can be used as an extension |
| 37 | +# if defined(_GLIBCXX_USE_LONG_LONG) |
| 38 | + |
33 | 39 | __extension__ typedef long long int rcpp_long_long_type;
|
34 | 40 | __extension__ typedef unsigned long long int rcpp_ulong_long_type;
|
35 |
| -#define RCPP_HAS_LONG_LONG_TYPES |
36 |
| -#endif |
37 |
| - |
38 |
| -#endif |
39 |
| -#endif |
| 41 | +# define RCPP_HAS_LONG_LONG_TYPES |
40 | 42 |
|
41 |
| -// The Rtools toolchain provides long long on 64bit Windows, |
42 |
| -// but using those types directly in C++98 mode can trigger |
43 |
| -// compiler warnings: |
44 |
| -// |
45 |
| -// warning: ISO C++ 1998 does not support 'long long' [-Wlong-long] |
46 |
| -// |
47 |
| -// fortunately, glibc provides these types as aliases for int64_t |
48 |
| -// and uint64_t, which we can use as extensions in C++98 mode |
49 |
| -#if defined(_WIN32) && defined(_GLIBCXX_HAVE_INT64_T) && defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG) |
50 |
| -# include <stdint.h> |
| 43 | +// check to see if 'long long' is an alias for 'int64_t' |
| 44 | +# elif defined(_GLIBCXX_HAVE_INT64_T) && defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG) |
| 45 | +# include <stdint.h> |
51 | 46 | typedef int64_t rcpp_long_long_type;
|
52 | 47 | typedef uint64_t rcpp_ulong_long_type;
|
53 |
| -#define RCPP_HAS_LONG_LONG_TYPES |
| 48 | +# define RCPP_HAS_LONG_LONG_TYPES |
| 49 | + |
| 50 | +# endif |
54 | 51 | #endif
|
55 | 52 |
|
| 53 | + |
56 | 54 | #endif
|
0 commit comments