|
22 | 22 | #ifndef RCPP_LONG_LONG_H |
23 | 23 | #define RCPP_LONG_LONG_H |
24 | 24 |
|
25 | | -// This does not work as C++98, our default, has no long long support. |
26 | | -// So we are wrapping another layer of C++11 test around it. Feel free |
27 | | -// to add a boolean OR with another suitably #define'd variable which |
28 | | -// has to be OFF by default to restore the old behaviour. |
| 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 | 29 |
|
30 | 30 | #ifdef __GNUC__ |
31 | | -#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined (__clang__) && defined(__LP64__)) |
| 31 | + #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined (__clang__) && defined(__LP64__)) |
32 | 32 |
|
33 | | -// long long and unssigned long long support. |
34 | | -// |
35 | | -// given the current restriction of what might go to CRAN |
36 | | -// we can only use long long if we are running a gcc compatible (e.g. clang) |
37 | | -// compiler and the type is actually available (hence the test for __LONG_LONG_MAX__) |
38 | | -// even then, we cannot use long long as is, we first have to "hide" it |
39 | | -// behind the __extension__ so that -pedantic stops giving warnings about |
40 | | -// compliance with C++98 |
41 | | -// |
42 | | -// client code may use the facilities we provide for long long (wrap, etc ...) |
43 | | -// but not using long long directly, because then it is not CRAN proof. |
44 | | -// So client code must use the rcpp_long_long_type and rcpp_ulong_long_type |
45 | | -// types |
46 | | -// |
47 | | -// e.g. code like this is not good: |
48 | | -// |
49 | | -// long long x = 2 ; |
50 | | -// |
51 | | -// but code like this is CRAN proof |
52 | | -// |
53 | | -// rcpp_long_long_type x = 2 ; |
54 | | -// |
55 | | -// Note that if you don't distribute your code to CRAN and you don't use the |
56 | | -// -pedantic option, then you can use long long |
57 | | -#if defined(__GNUC__) && defined(__LONG_LONG_MAX__) |
58 | | - __extension__ typedef long long int rcpp_long_long_type; |
59 | | - __extension__ typedef unsigned long long int rcpp_ulong_long_type; |
60 | | - #define RCPP_HAS_LONG_LONG_TYPES |
| 33 | + #if defined(__GNUC__) && defined(__LONG_LONG_MAX__) |
| 34 | + __extension__ typedef long long int rcpp_long_long_type; |
| 35 | + __extension__ typedef unsigned long long int rcpp_ulong_long_type; |
| 36 | + #define RCPP_HAS_LONG_LONG_TYPES |
| 37 | + #endif |
| 38 | + |
| 39 | + #endif |
61 | 40 | #endif |
62 | 41 |
|
| 42 | + |
63 | 43 | #if defined(RCPP_HAS_LONG_LONG_TYPES) |
64 | 44 |
|
65 | 45 | namespace Rcpp{ |
66 | | -namespace traits{ |
| 46 | + namespace traits{ |
67 | 47 |
|
68 | | - template<> struct r_sexptype_traits<rcpp_long_long_type>{ enum{ rtype = REALSXP } ; } ; |
69 | | - template<> struct r_sexptype_traits<rcpp_ulong_long_type>{ enum{ rtype = REALSXP } ; } ; |
| 48 | + template<> struct r_sexptype_traits<rcpp_long_long_type>{ enum{ rtype = REALSXP } ; } ; |
| 49 | + template<> struct r_sexptype_traits<rcpp_ulong_long_type>{ enum{ rtype = REALSXP } ; } ; |
70 | 50 |
|
71 | | - template<> struct r_type_traits<rcpp_long_long_type>{ typedef r_type_primitive_tag r_category ; } ; |
72 | | - template<> struct r_type_traits< std::pair<const std::string,rcpp_long_long_type> >{ typedef r_type_primitive_tag r_category ; } ; |
73 | | - template<> struct r_type_traits<rcpp_ulong_long_type>{ typedef r_type_primitive_tag r_category ; } ; |
74 | | - template<> struct r_type_traits< std::pair<const std::string,rcpp_ulong_long_type> >{ typedef r_type_primitive_tag r_category ; } ; |
| 51 | + template<> struct r_type_traits<rcpp_long_long_type>{ typedef r_type_primitive_tag r_category ; } ; |
| 52 | + template<> struct r_type_traits< std::pair<const std::string,rcpp_long_long_type> >{ typedef r_type_primitive_tag r_category ; } ; |
| 53 | + template<> struct r_type_traits<rcpp_ulong_long_type>{ typedef r_type_primitive_tag r_category ; } ; |
| 54 | + template<> struct r_type_traits< std::pair<const std::string,rcpp_ulong_long_type> >{ typedef r_type_primitive_tag r_category ; } ; |
75 | 55 |
|
76 | | - template <> struct wrap_type_traits<rcpp_long_long_type> { typedef wrap_type_primitive_tag wrap_category; } ; |
77 | | - template <> struct wrap_type_traits<rcpp_ulong_long_type> { typedef wrap_type_primitive_tag wrap_category; } ; |
78 | | -} |
| 56 | + template <> struct wrap_type_traits<rcpp_long_long_type> { typedef wrap_type_primitive_tag wrap_category; } ; |
| 57 | + template <> struct wrap_type_traits<rcpp_ulong_long_type> { typedef wrap_type_primitive_tag wrap_category; } ; |
| 58 | + } |
79 | 59 | } |
80 | 60 | #endif |
81 | 61 |
|
82 | 62 | #endif |
83 | | -#endif |
84 | | - |
85 | | -#endif |
0 commit comments