[Rcpp-commits] r4521 - in pkg/Rcpp: . inst inst/include/Rcpp/platform

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Sep 19 17:16:41 CEST 2013


Author: romain
Date: 2013-09-19 17:16:41 +0200 (Thu, 19 Sep 2013)
New Revision: 4521

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/NEWS.Rd
   pkg/Rcpp/inst/include/Rcpp/platform/compiler.h
Log:
less restritive support for long long

Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2013-09-19 09:08:54 UTC (rev 4520)
+++ pkg/Rcpp/ChangeLog	2013-09-19 15:16:41 UTC (rev 4521)
@@ -4,6 +4,9 @@
         long standing feature request from Murray. 
         * R/Attributes.R : Added the helper demangle and sizeof functions
         * man/demangle.Rd : Documentation for demangle and sizeof
+        * include/Rcpp/platform/compiler.h : less restritive support of long long 
+        types. But still behind a test for gcc and a test for the availability
+        of the type, and the __extension__. -pedantic does not warn about it
 
 2013-09-18  JJ Allaire  <jj at rstudio.org>
 

Modified: pkg/Rcpp/inst/NEWS.Rd
===================================================================
--- pkg/Rcpp/inst/NEWS.Rd	2013-09-19 09:08:54 UTC (rev 4520)
+++ pkg/Rcpp/inst/NEWS.Rd	2013-09-19 15:16:41 UTC (rev 4521)
@@ -43,6 +43,12 @@
       file
       \item \code{RcppLdFlags()}, often used in \code{Makevars} files of
       packages using \pkg{Rcpp}, is now exported from the package namespace.
+      \item Less restritive support for \code{long long}. If we are using a gcc 
+      compatible compiler and the long long type is available (i.e. the 
+      \code{__LONG_LONG_MAX__} is defined, then we have typedefs 
+      \code{rcpp_long_long_type} and \code{rcpp_ulong_long_type} that are defined
+      behind a gcc \code{__extension__}. This way, we can create useful 
+      features supporting long long, while having \code{-pedantic} not warn about it. 
     }
     \item Changes in Attributes:
     \itemize{

Modified: pkg/Rcpp/inst/include/Rcpp/platform/compiler.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/platform/compiler.h	2013-09-19 09:08:54 UTC (rev 4520)
+++ pkg/Rcpp/inst/include/Rcpp/platform/compiler.h	2013-09-19 15:16:41 UTC (rev 4521)
@@ -177,14 +177,34 @@
   #define RCPP_HAS_DEMANGLING
 #endif
 
-#ifdef __GNUC__
-#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined (__clang__) && defined(__LP64__))
-#ifdef __LONG_LONG_MAX__
+// long long and unssigned long long support. 
+//
+// given the current restriction of what might go to CRAN
+// we can only use long long if we are running a gcc compatible (e.g. clang)
+// compiler and the type is actually available (hence the test for __LONG_LONG_MAX__)
+// even then, we cannot use long long as is, we first have to "hide" it
+// behind the __extension__ so that -pedantic stops giving warnings about 
+// compliance with C++98
+// 
+// client code may use the facilities we provide for long long (wrap, etc ...)
+// but not using long long directly, because then it is not CRAN proof. 
+// So client code must use the rcpp_long_long_type and rcpp_ulong_long_type 
+// types 
+//
+// e.g. code like this is not good: 
+//
+// long long x = 2 ;
+//
+// but code like this is CRAN proof
+//
+// rcpp_long_long_type x = 2 ;
+//
+// Note that if you don't distribute your code to CRAN and you don't use the 
+// -pedantic option, then you can use long long
+#if defined(__GNUC__) &&  defined(__LONG_LONG_MAX__)
     __extension__ typedef long long int rcpp_long_long_type;
     __extension__ typedef unsigned long long int rcpp_ulong_long_type;
     #define RCPP_HAS_LONG_LONG_TYPES
 #endif
-#endif
-#endif
 
 #endif



More information about the Rcpp-commits mailing list