[Rcpp-commits] r4525 - pkg/Rcpp/inst/include/Rcpp

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Sep 20 14:40:57 CEST 2013


Author: edd
Date: 2013-09-20 14:40:57 +0200 (Fri, 20 Sep 2013)
New Revision: 4525

Modified:
   pkg/Rcpp/inst/include/Rcpp/longlong.h
Log:
shortened / corrected the long comment: 'long long' is on with either clang, or -std=c++11


Modified: pkg/Rcpp/inst/include/Rcpp/longlong.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/longlong.h	2013-09-20 00:01:34 UTC (rev 4524)
+++ pkg/Rcpp/inst/include/Rcpp/longlong.h	2013-09-20 12:40:57 UTC (rev 4525)
@@ -22,64 +22,41 @@
 #ifndef RCPP_LONG_LONG_H
 #define RCPP_LONG_LONG_H
 
-// This does not work as C++98, our default, has no long long support.
-// So we are wrapping another layer of C++11 test around it. Feel free
-// to add a boolean OR with another suitably #define'd variable which
-// has to be OFF by default to restore the old behaviour.
+// 'long long' is a C99 extension and (as of fall 2013) still
+// forbidden by CRAN which stick with the C++98 standard predating it.
+// One way to get 'long long' is to switch to C++11, another is to use
+// clang++ from the llvm project.
 
 #ifdef __GNUC__
-#if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined (__clang__) && defined(__LP64__))
+  #if defined(__GXX_EXPERIMENTAL_CXX0X__) || (defined (__clang__) && defined(__LP64__))
 
-// 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
+    #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
 
+
 #if defined(RCPP_HAS_LONG_LONG_TYPES)
 
 namespace Rcpp{
-namespace traits{
+    namespace traits{
 
-    template<> struct r_sexptype_traits<rcpp_long_long_type>{ enum{ rtype = REALSXP } ; } ;
-    template<> struct r_sexptype_traits<rcpp_ulong_long_type>{ enum{ rtype = REALSXP } ; } ;
+        template<> struct r_sexptype_traits<rcpp_long_long_type>{ enum{ rtype = REALSXP } ; } ;
+        template<> struct r_sexptype_traits<rcpp_ulong_long_type>{ enum{ rtype = REALSXP } ; } ;
     
-    template<> struct r_type_traits<rcpp_long_long_type>{ typedef r_type_primitive_tag r_category ; } ;
-    template<> struct r_type_traits< std::pair<const std::string,rcpp_long_long_type> >{ typedef r_type_primitive_tag r_category ; } ;
-    template<> struct r_type_traits<rcpp_ulong_long_type>{ typedef r_type_primitive_tag r_category ; } ;
-    template<> struct r_type_traits< std::pair<const std::string,rcpp_ulong_long_type> >{ typedef r_type_primitive_tag r_category ; } ;
+        template<> struct r_type_traits<rcpp_long_long_type>{ typedef r_type_primitive_tag r_category ; } ;
+        template<> struct r_type_traits< std::pair<const std::string,rcpp_long_long_type> >{ typedef r_type_primitive_tag r_category ; } ;
+        template<> struct r_type_traits<rcpp_ulong_long_type>{ typedef r_type_primitive_tag r_category ; } ;
+        template<> struct r_type_traits< std::pair<const std::string,rcpp_ulong_long_type> >{ typedef r_type_primitive_tag r_category ; } ;
     
-    template <> struct wrap_type_traits<rcpp_long_long_type> { typedef wrap_type_primitive_tag wrap_category; } ;
-    template <> struct wrap_type_traits<rcpp_ulong_long_type> { typedef wrap_type_primitive_tag wrap_category; } ;
+        template <> struct wrap_type_traits<rcpp_long_long_type> { typedef wrap_type_primitive_tag wrap_category; } ;
+        template <> struct wrap_type_traits<rcpp_ulong_long_type> { typedef wrap_type_primitive_tag wrap_category; } ;
+    }
 }
-}
 #endif
 
 #endif
-#endif
-
-#endif



More information about the Rcpp-commits mailing list