Skip to content

Commit b6fa5fd

Browse files
committed
alternate way to grab 'long long' type
1 parent 06b1f62 commit b6fa5fd

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

inst/include/Rcpp/longlong.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,18 @@ __extension__ typedef unsigned long long int rcpp_ulong_long_type;
3838
#endif
3939
#endif
4040

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;
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>
51+
typedef int64_t rcpp_long_long_type;
52+
typedef uint64_t rcpp_ulong_long_type;
4553
#define RCPP_HAS_LONG_LONG_TYPES
4654
#endif
4755

0 commit comments

Comments
 (0)