Skip to content

Commit f9d05e6

Browse files
committed
rework long long detection
1 parent b6fa5fd commit f9d05e6

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

inst/include/Rcpp/longlong.h

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +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' can be used as an extension
37+
# if defined(_GLIBCXX_USE_LONG_LONG)
38+
3339
__extension__ typedef long long int rcpp_long_long_type;
3440
__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
4042

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>
5146
typedef int64_t rcpp_long_long_type;
5247
typedef uint64_t rcpp_ulong_long_type;
53-
#define RCPP_HAS_LONG_LONG_TYPES
48+
# define RCPP_HAS_LONG_LONG_TYPES
49+
50+
# endif
5451
#endif
5552

53+
5654
#endif

0 commit comments

Comments
 (0)