Skip to content

Commit 4ab36d5

Browse files
committed
shortened / corrected the long comment: 'long long' is on with either clang, or -std=c++11
1 parent e7cad54 commit 4ab36d5

File tree

1 file changed

+23
-46
lines changed

1 file changed

+23
-46
lines changed

inst/include/Rcpp/longlong.h

Lines changed: 23 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -22,64 +22,41 @@
2222
#ifndef RCPP_LONG_LONG_H
2323
#define RCPP_LONG_LONG_H
2424

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.
2929

3030
#ifdef __GNUC__
31-
#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined (__clang__) && defined(__LP64__))
31+
#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined (__clang__) && defined(__LP64__))
3232

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
6140
#endif
6241

42+
6343
#if defined(RCPP_HAS_LONG_LONG_TYPES)
6444

6545
namespace Rcpp{
66-
namespace traits{
46+
namespace traits{
6747

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 } ; } ;
7050

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 ; } ;
7555

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+
}
7959
}
8060
#endif
8161

8262
#endif
83-
#endif
84-
85-
#endif

0 commit comments

Comments
 (0)