Skip to content

Commit 1a0d3c5

Browse files
authored
Merge pull request #829 from RcppCore/feature/windows-long-long
alternate way to grab 'long long' type
2 parents 06b1f62 + a3f9128 commit 1a0d3c5

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

inst/include/Rcpp/longlong.h

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,33 @@
2222
#ifndef RCPP_LONG_LONG_H
2323
#define RCPP_LONG_LONG_H
2424

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' is an alias for 'int64_t'
37+
# if defined(_GLIBCXX_HAVE_INT64_T) && defined(_GLIBCXX_HAVE_INT64_T_LONG_LONG)
38+
# include <stdint.h>
39+
typedef int64_t rcpp_long_long_type;
40+
typedef uint64_t rcpp_ulong_long_type;
41+
# define RCPP_HAS_LONG_LONG_TYPES
42+
43+
// check to see if this is an older C++ compiler, but extensions are enabled
44+
# elif defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined(__clang__) && defined(__LP64__))
45+
# if defined(__LONG_LONG_MAX__)
3346
__extension__ typedef long long int rcpp_long_long_type;
3447
__extension__ typedef unsigned long long int rcpp_ulong_long_type;
35-
#define RCPP_HAS_LONG_LONG_TYPES
36-
#endif
37-
38-
#endif
39-
#endif
48+
# define RCPP_HAS_LONG_LONG_TYPES
49+
# endif
50+
# endif
4051

41-
// The Rtools toolchain provides long long on 64bit Windows
42-
#ifdef _WIN64
43-
typedef long long rcpp_long_long_type;
44-
typedef unsigned long long rcpp_ulong_long_type;
45-
#define RCPP_HAS_LONG_LONG_TYPES
4652
#endif
4753

4854
#endif

0 commit comments

Comments
 (0)