Skip to content

Commit a522edb

Browse files
less restritive support for long long
1 parent d0077bf commit a522edb

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
long standing feature request from Murray.
55
* R/Attributes.R : Added the helper demangle and sizeof functions
66
* man/demangle.Rd : Documentation for demangle and sizeof
7+
* include/Rcpp/platform/compiler.h : less restritive support of long long
8+
types. But still behind a test for gcc and a test for the availability
9+
of the type, and the __extension__. -pedantic does not warn about it
710

811
2013-09-18 JJ Allaire <jj@rstudio.org>
912

inst/NEWS.Rd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
file
4444
\item \code{RcppLdFlags()}, often used in \code{Makevars} files of
4545
packages using \pkg{Rcpp}, is now exported from the package namespace.
46+
\item Less restritive support for \code{long long}. If we are using a gcc
47+
compatible compiler and the long long type is available (i.e. the
48+
\code{__LONG_LONG_MAX__} is defined, then we have typedefs
49+
\code{rcpp_long_long_type} and \code{rcpp_ulong_long_type} that are defined
50+
behind a gcc \code{__extension__}. This way, we can create useful
51+
features supporting long long, while having \code{-pedantic} not warn about it.
4652
}
4753
\item Changes in Attributes:
4854
\itemize{

inst/include/Rcpp/platform/compiler.h

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,34 @@
177177
#define RCPP_HAS_DEMANGLING
178178
#endif
179179

180-
#ifdef __GNUC__
181-
#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined (__clang__) && defined(__LP64__))
182-
#ifdef __LONG_LONG_MAX__
180+
// long long and unssigned long long support.
181+
//
182+
// given the current restriction of what might go to CRAN
183+
// we can only use long long if we are running a gcc compatible (e.g. clang)
184+
// compiler and the type is actually available (hence the test for __LONG_LONG_MAX__)
185+
// even then, we cannot use long long as is, we first have to "hide" it
186+
// behind the __extension__ so that -pedantic stops giving warnings about
187+
// compliance with C++98
188+
//
189+
// client code may use the facilities we provide for long long (wrap, etc ...)
190+
// but not using long long directly, because then it is not CRAN proof.
191+
// So client code must use the rcpp_long_long_type and rcpp_ulong_long_type
192+
// types
193+
//
194+
// e.g. code like this is not good:
195+
//
196+
// long long x = 2 ;
197+
//
198+
// but code like this is CRAN proof
199+
//
200+
// rcpp_long_long_type x = 2 ;
201+
//
202+
// Note that if you don't distribute your code to CRAN and you don't use the
203+
// -pedantic option, then you can use long long
204+
#if defined(__GNUC__) && defined(__LONG_LONG_MAX__)
183205
__extension__ typedef long long int rcpp_long_long_type;
184206
__extension__ typedef unsigned long long int rcpp_ulong_long_type;
185207
#define RCPP_HAS_LONG_LONG_TYPES
186208
#endif
187-
#endif
188-
#endif
189209

190210
#endif

0 commit comments

Comments
 (0)