Boost logo

Boost :

From: Aaron W. LaFramboise (aaronrabiddog51_at_[hidden])
Date: 2004-08-15 03:38:20


This is a followup from prior threads:
TT_AUX_IS_CONVERTIBLE_FROM_FLOAT_CV_SPEC in
type_traits/is_convertable.hpp:
http://thread.gmane.org/gmane.comp.lib.boost.devel/106708
long long support with GCC:
http://thread.gmane.org/gmane.comp.lib.boost.user/6693

The following patch is another attempt to get long long support working,
in a manner acceptable with Boost, even when -std=c++98 and -pedantic
are specified. In particular, GCC supports long long in all modes, but
__extension__ is required to quiet errors and warnings.

It is possible that other C++ compilers with a similar situation
regarding long long might be able to use this patch constructively.

In short, typedefs are added for long long and unsigned long long in
cstdint.hpp, and all uses of these typenames in the headers are changed
to use these new names.

Aaron W. LaFramboise

Index: boost/boost/cast.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/cast.hpp,v
retrieving revision 1.22
diff -c -p -r1.22 cast.hpp
*** boost/boost/cast.hpp 11 Aug 2004 10:59:33 -0000 1.22
--- boost/boost/cast.hpp 15 Aug 2004 08:25:07 -0000
***************
*** 45,50 ****
--- 45,51 ----
  # include <boost/config.hpp>
  # include <cassert>
  # include <typeinfo>
+ # include <boost/cstdint.hpp>
  # include <boost/type.hpp>
  # include <boost/limits.hpp>
  # include <boost/detail/select_type.hpp>
*************** namespace boost
*** 156,166 ****
        // long / unsigned long long. Not intended to be full
        // numeric_limits replacements, but good enough for numeric_cast<>
        template <>
! struct fixed_numeric_limits_base<long long, false>
        {
            BOOST_STATIC_CONSTANT(bool, is_specialized = true);
            BOOST_STATIC_CONSTANT(bool, is_signed = true);
! static long long max BOOST_PREVENT_MACRO_SUBSTITUTION ()
            {
  # ifdef LONGLONG_MAX
                return LONGLONG_MAX;
--- 157,167 ----
        // long / unsigned long long. Not intended to be full
        // numeric_limits replacements, but good enough for numeric_cast<>
        template <>
! struct fixed_numeric_limits_base<longlong, false>
        {
            BOOST_STATIC_CONSTANT(bool, is_specialized = true);
            BOOST_STATIC_CONSTANT(bool, is_signed = true);
! static longlong max BOOST_PREVENT_MACRO_SUBSTITUTION ()
            {
  # ifdef LONGLONG_MAX
                return LONGLONG_MAX;
*************** namespace boost
*** 169,175 ****
  # endif
            }

! static long long min BOOST_PREVENT_MACRO_SUBSTITUTION ()
            {
  # ifdef LONGLONG_MIN
                return LONGLONG_MIN;
--- 170,176 ----
  # endif
            }

! static longlong min BOOST_PREVENT_MACRO_SUBSTITUTION ()
            {
  # ifdef LONGLONG_MIN
                return LONGLONG_MIN;
*************** namespace boost
*** 180,190 ****
        };

        template <>
! struct fixed_numeric_limits_base<unsigned long long, false>
        {
            BOOST_STATIC_CONSTANT(bool, is_specialized = true);
            BOOST_STATIC_CONSTANT(bool, is_signed = false);
! static unsigned long long max
BOOST_PREVENT_MACRO_SUBSTITUTION ()
            {
  # ifdef ULONGLONG_MAX
                return ULONGLONG_MAX;
--- 181,191 ----
        };

        template <>
! struct fixed_numeric_limits_base<ulonglong, false>
        {
            BOOST_STATIC_CONSTANT(bool, is_specialized = true);
            BOOST_STATIC_CONSTANT(bool, is_signed = false);
! static ulonglong max BOOST_PREVENT_MACRO_SUBSTITUTION ()
            {
  # ifdef ULONGLONG_MAX
                return ULONGLONG_MAX;
*************** namespace boost
*** 193,199 ****
  # endif
            }

! static unsigned long long min
BOOST_PREVENT_MACRO_SUBSTITUTION () { return 0; }
        };
  # endif
      } // namespace detail
--- 194,200 ----
  # endif
            }

! static ulonglong min BOOST_PREVENT_MACRO_SUBSTITUTION () {
return 0; }
        };
  # endif
      } // namespace detail
Index: boost/boost/concept_check.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/concept_check.hpp,v
retrieving revision 1.28
diff -c -p -r1.28 concept_check.hpp
*** boost/boost/concept_check.hpp 26 Jul 2004 00:31:58 -0000 1.28
--- boost/boost/concept_check.hpp 15 Aug 2004 08:25:10 -0000
***************
*** 16,21 ****
--- 16,22 ----
  #define BOOST_CONCEPT_CHECKS_HPP

  #include <boost/config.hpp>
+ #include <boost/cstdint.hpp>
  #include <boost/iterator.hpp>
  #include <boost/type_traits/conversion_traits.hpp>
  #include <utility>
*************** struct require_same { typedef T type; };
*** 179,185 ****
    template <> struct SignedIntegerConcept<int> { void constraints() {} };
    template <> struct SignedIntegerConcept<long> { void constraints() {} };
  # if defined(BOOST_HAS_LONG_LONG)
! template <> struct SignedIntegerConcept<long long> { void
constraints() {} };
  # endif
    // etc.
  #endif
--- 180,186 ----
    template <> struct SignedIntegerConcept<int> { void constraints() {} };
    template <> struct SignedIntegerConcept<long> { void constraints() {} };
  # if defined(BOOST_HAS_LONG_LONG)
! template <> struct SignedIntegerConcept<longlong> { void
constraints() {} };
  # endif
    // etc.
  #endif
Index: boost/boost/cstdint.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/cstdint.hpp,v
retrieving revision 1.33
diff -c -p -r1.33 cstdint.hpp
*** boost/boost/cstdint.hpp 10 Aug 2004 12:53:33 -0000 1.33
--- boost/boost/cstdint.hpp 15 Aug 2004 08:25:11 -0000
*************** namespace boost
*** 278,283 ****
--- 278,305 ----

  #endif // BOOST_HAS_STDINT_H

+
+ #ifdef BOOST_HAS_LONG_LONG
+
+ namespace boost {
+
+ # ifdef __GNUC__
+
+ __extension__ typedef long long longlong;
+ __extension__ typedef unsigned long long ulonglong;
+
+ # else
+
+ typedef long long longlong;
+ typedef unsigned long long ulonglong;
+
+ # endif
+
+ } // namespace boost
+
+ # endif // BOOST_HAS_LONG_LONG
+
+
  #endif // BOOST_CSTDINT_HPP

Index: boost/boost/integer_fwd.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/integer_fwd.hpp,v
retrieving revision 1.3
diff -c -p -r1.3 integer_fwd.hpp
*** boost/boost/integer_fwd.hpp 11 Aug 2004 10:59:33 -0000 1.3
--- boost/boost/integer_fwd.hpp 15 Aug 2004 08:25:11 -0000
***************
*** 12,19 ****
  #include <climits> // for UCHAR_MAX, etc.
  #include <cstddef> // for std::size_t

! #include <boost/config.hpp> // for BOOST_NO_INTRINSIC_WCHAR_T
! #include <boost/limits.hpp> // for std::numeric_limits

  namespace boost
--- 12,20 ----
  #include <climits> // for UCHAR_MAX, etc.
  #include <cstddef> // for std::size_t

! #include <boost/config.hpp> // for BOOST_NO_INTRINSIC_WCHAR_T
! #include <boost/cstdint.hpp> // for longlong
! #include <boost/limits.hpp> // for std::numeric_limits

  namespace boost
*************** template < >
*** 67,76 ****

  #ifdef ULLONG_MAX
  template < >
! class integer_traits< long long >;

  template < >
! class integer_traits< unsigned long long >;
  #endif

--- 68,77 ----

  #ifdef ULLONG_MAX
  template < >
! class integer_traits< longlong >;

  template < >
! class integer_traits< ulonglong >;
  #endif

Index: boost/boost/limits.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/limits.hpp,v
retrieving revision 1.11
diff -c -p -r1.11 limits.hpp
*** boost/boost/limits.hpp 10 Aug 2004 12:53:33 -0000 1.11
--- boost/boost/limits.hpp 15 Aug 2004 08:25:12 -0000
***************
*** 12,17 ****
--- 12,18 ----
  #define BOOST_LIMITS

  #include <boost/config.hpp>
+ #include <boost/cstdint.hpp>

  #ifdef BOOST_NO_LIMITS
  # include <boost/detail/limits.hpp>
***************
*** 25,31 ****
  #ifdef BOOST_HAS_MS_INT64
  # define BOOST_LLT __int64
  #else
! # define BOOST_LLT long long
  #endif

  namespace std
--- 26,32 ----
  #ifdef BOOST_HAS_MS_INT64
  # define BOOST_LLT __int64
  #else
! # define BOOST_LLT longlong
  #endif

  namespace std
Index: boost/boost/iterator/counting_iterator.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/iterator/counting_iterator.hpp,v
retrieving revision 1.5
diff -c -p -r1.5 counting_iterator.hpp
*** boost/boost/iterator/counting_iterator.hpp 26 Jul 2004 00:31:59
-0000 1.5
--- boost/boost/iterator/counting_iterator.hpp 15 Aug 2004 08:25:14 -0000
***************
*** 6,11 ****
--- 6,12 ----
  # define COUNTING_ITERATOR_DWA200348_HPP

  # include <boost/iterator/iterator_adaptor.hpp>
+ # include <boost/cstdint.hpp>
  # include <boost/detail/numeric_traits.hpp>
  # include <boost/mpl/bool.hpp>
  # include <boost/mpl/if.hpp>
*************** namespace detail
*** 57,67 ****

  # if defined(BOOST_HAS_LONG_LONG)
    template <>
! struct is_numeric<long long>
      : mpl::true_ {};

    template <>
! struct is_numeric<unsigned long long>
      : mpl::true_ {};
  # endif

--- 58,68 ----

  # if defined(BOOST_HAS_LONG_LONG)
    template <>
! struct is_numeric<longlong>
      : mpl::true_ {};

    template <>
! struct is_numeric<ulonglong>
      : mpl::true_ {};
  # endif

Index: boost/boost/numeric/interval/detail/ppc_rounding_control.hpp
===================================================================
RCS file:
/cvsroot/boost/boost/boost/numeric/interval/detail/ppc_rounding_control.hpp,v
retrieving revision 1.3
diff -c -p -r1.3 ppc_rounding_control.hpp
*** boost/boost/numeric/interval/detail/ppc_rounding_control.hpp 19 Jul
2004 21:38:06 -0000 1.3
--- boost/boost/numeric/interval/detail/ppc_rounding_control.hpp 15 Aug
2004 08:25:18 -0000
*************** namespace interval_lib {
*** 25,31 ****
  namespace detail {

  typedef union {
! long long int imode;
    double dmode;
  } rounding_mode_struct;

--- 25,31 ----
  namespace detail {

  typedef union {
! __extension__ long long int imode;
    double dmode;
  } rounding_mode_struct;

Index: boost/boost/python/type_id.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/python/type_id.hpp,v
retrieving revision 1.15
diff -c -p -r1.15 type_id.hpp
*** boost/boost/python/type_id.hpp 26 Jul 2004 00:32:05 -0000 1.15
--- boost/boost/python/type_id.hpp 15 Aug 2004 08:25:20 -0000
***************
*** 11,16 ****
--- 11,17 ----
  # include <boost/operators.hpp>
  # include <typeinfo>
  # include <cstring>
+ # include <boost/cstdint.hpp>
  # include <boost/static_assert.hpp>
  # include <boost/detail/workaround.hpp>
  # include <boost/type_traits/same_traits.hpp>
*************** BOOST_PYTHON_SIGNED_INTEGRAL_TYPE_ID(lon
*** 100,106 ****
  // using Python's macro instead of Boost's - we don't seem to get the
  // config right all the time.
  # ifdef HAVE_LONG_LONG
! BOOST_PYTHON_SIGNED_INTEGRAL_TYPE_ID(long long)
  # endif
  # undef BOOST_PYTHON_SIGNED_INTEGRAL_TYPE_ID
  # endif
--- 101,107 ----
  // using Python's macro instead of Boost's - we don't seem to get the
  // config right all the time.
  # ifdef HAVE_LONG_LONG
! BOOST_PYTHON_SIGNED_INTEGRAL_TYPE_ID(longlong)
  # endif
  # undef BOOST_PYTHON_SIGNED_INTEGRAL_TYPE_ID
  # endif
Index: boost/boost/python/detail/wrap_python.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/python/detail/wrap_python.hpp,v
retrieving revision 1.18
diff -c -p -r1.18 wrap_python.hpp
*** boost/boost/python/detail/wrap_python.hpp 26 Jul 2004 00:32:07
-0000 1.18
--- boost/boost/python/detail/wrap_python.hpp 15 Aug 2004 08:25:21 -0000
***************
*** 25,30 ****
--- 25,31 ----
  // which confuses Boost's config
  //
  #include <limits.h>
+ #include <boost/cstdint.hpp>
  #ifndef ULONG_MAX
  # define BOOST_PYTHON_ULONG_MAX_UNDEFINED
  #endif
*************** typedef int pid_t;
*** 86,92 ****
  # endif

  # define HAVE_LONG_LONG 1
! # define LONG_LONG long long
  # endif

  # elif defined(__MWERKS__)
--- 87,93 ----
  # endif

  # define HAVE_LONG_LONG 1
! # define LONG_LONG longlong
  # endif

  # elif defined(__MWERKS__)
Index: boost/boost/spirit/phoenix/operators.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/spirit/phoenix/operators.hpp,v
retrieving revision 1.7
diff -c -p -r1.7 operators.hpp
*** boost/boost/spirit/phoenix/operators.hpp 28 Jul 2004 01:57:45 -0000 1.7
--- boost/boost/spirit/phoenix/operators.hpp 15 Aug 2004 08:25:27 -0000
***************
*** 23,28 ****
--- 23,29 ----
  #include <boost/spirit/phoenix/actor.hpp>
  #include <boost/spirit/phoenix/composite.hpp>
  #include <boost/config.hpp>
+ #include <boost/cstdint.hpp>

///////////////////////////////////////////////////////////////////////////////
  namespace phoenix {
*************** template <> struct rank<long>
*** 373,380 ****
  template <> struct rank<unsigned long> { static int const value =
100; };

  #ifdef BOOST_HAS_LONG_LONG
! template <> struct rank<long long> { static int const value =
110; };
! template <> struct rank<unsigned long long> { static int const value =
120; };
  #endif

  template <> struct rank<float> { static int const value =
130; };
--- 374,381 ----
  template <> struct rank<unsigned long> { static int const value =
100; };

  #ifdef BOOST_HAS_LONG_LONG
! template <> struct rank<boost::longlong> { static int const value =
110; };
! template <> struct rank<boost::ulonglong> { static int const value =
120; };
  #endif

  template <> struct rank<float> { static int const value =
130; };
Index: boost/boost/spirit/utility/chset.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/spirit/utility/chset.hpp,v
retrieving revision 1.6
diff -c -p -r1.6 chset.hpp
*** boost/boost/spirit/utility/chset.hpp 9 Jul 2004 08:28:06 -0000 1.6
--- boost/boost/spirit/utility/chset.hpp 15 Aug 2004 08:25:27 -0000
***************
*** 14,19 ****
--- 14,20 ----
  #include <boost/shared_ptr.hpp>
  #include <boost/spirit/core/primitives/primitives.hpp>
  #include <boost/spirit/utility/impl/chset/basic_chset.hpp>
+ #include <boost/cstdint.hpp>

///////////////////////////////////////////////////////////////////////////////
  namespace boost { namespace spirit {
*************** chset_p(unsigned long ch)
*** 164,177 ****

  #ifdef BOOST_HAS_LONG_LONG
  //////////////////////////////////
! inline chset<long long>
! chset_p(long long ch)
! { return chset<long long>(ch); }

  //////////////////////////////////
! inline chset<unsigned long long>
! chset_p(unsigned long long ch)
! { return chset<unsigned long long>(ch); }
  #endif

///////////////////////////////////////////////////////////////////////////////
--- 165,178 ----

  #ifdef BOOST_HAS_LONG_LONG
  //////////////////////////////////
! inline chset<longlong>
! chset_p(longlong ch)
! { return chset<longlong>(ch); }

  //////////////////////////////////
! inline chset<ulonglong>
! chset_p(ulonglong ch)
! { return chset<ulonglong>(ch); }
  #endif

///////////////////////////////////////////////////////////////////////////////
Index: boost/boost/type_traits/is_convertible.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/type_traits/is_convertible.hpp,v
retrieving revision 1.25
diff -c -p -r1.25 is_convertible.hpp
*** boost/boost/type_traits/is_convertible.hpp 6 Jan 2004 13:37:10
-0000 1.25
--- boost/boost/type_traits/is_convertible.hpp 15 Aug 2004 08:25:29 -0000
***************
*** 22,27 ****
--- 22,29 ----
  # include "boost/type_traits/is_void.hpp"
  #endif

+ #include "boost/cstdint.hpp"
+
  // should be always the last #include directive
  #include "boost/type_traits/detail/bool_trait_def.hpp"

*************** BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_converti
*** 260,266 ****
      TT_AUX_IS_CONVERTIBLE_SPEC_2(F,short) \
      TT_AUX_IS_CONVERTIBLE_SPEC_2(F,int) \
      TT_AUX_IS_CONVERTIBLE_SPEC_2(F,long) \
! TT_AUX_IS_CONVERTIBLE_SPEC_2(F,long long) \
      /**/

  # define TT_AUX_IS_CONVERTIBLE_FROM_FLOAT_CV_SPEC(F) \
--- 262,269 ----
      TT_AUX_IS_CONVERTIBLE_SPEC_2(F,short) \
      TT_AUX_IS_CONVERTIBLE_SPEC_2(F,int) \
      TT_AUX_IS_CONVERTIBLE_SPEC_2(F,long) \
! TT_AUX_IS_CONVERTIBLE_SPEC(F,longlong) \
! TT_AUX_IS_CONVERTIBLE_SPEC(F,ulonglong) \
      /**/

  # define TT_AUX_IS_CONVERTIBLE_FROM_FLOAT_CV_SPEC(F) \
Index: boost/boost/type_traits/is_integral.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/type_traits/is_integral.hpp,v
retrieving revision 1.8
diff -c -p -r1.8 is_integral.hpp
*** boost/boost/type_traits/is_integral.hpp 1 May 2004 10:32:58 -0000 1.8
--- boost/boost/type_traits/is_integral.hpp 15 Aug 2004 08:25:29 -0000
***************
*** 10,15 ****
--- 10,16 ----
  #define BOOST_TT_IS_INTEGRAL_HPP_INCLUDED

  #include "boost/config.hpp"
+ #include "boost/cstdint.hpp"

  // should be the last #include
  #include "boost/type_traits/detail/bool_trait_def.hpp"
*************** BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_inte
*** 57,64 ****
  #endif

  # if defined(BOOST_HAS_LONG_LONG)
! BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_integral,unsigned long long,true)
! BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_integral,long long,true)
  #elif defined(BOOST_HAS_MS_INT64)
  BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_integral,unsigned __int64,true)
  BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_integral,__int64,true)
--- 58,65 ----
  #endif

  # if defined(BOOST_HAS_LONG_LONG)
! BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_integral,ulonglong,true)
! BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_integral,longlong,true)
  #elif defined(BOOST_HAS_MS_INT64)
  BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_integral,unsigned __int64,true)
  BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_integral,__int64,true)
Index: boost/boost/type_traits/type_with_alignment.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/type_traits/type_with_alignment.hpp,v
retrieving revision 1.24
diff -c -p -r1.24 type_with_alignment.hpp
*** boost/boost/type_traits/type_with_alignment.hpp 26 Jan 2004
12:20:03 -0000 1.24
--- boost/boost/type_traits/type_with_alignment.hpp 15 Aug 2004 08:25:30
-0000
***************
*** 8,13 ****
--- 8,14 ----
  #ifndef BOOST_TT_TYPE_WITH_ALIGNMENT_INCLUDED
  #define BOOST_TT_TYPE_WITH_ALIGNMENT_INCLUDED

+ #include "boost/cstdint.hpp"
  #include "boost/mpl/if.hpp"
  #include "boost/preprocessor/list/for_each_i.hpp"
  #include "boost/preprocessor/tuple/to_list.hpp"
*************** typedef int (alignment_dummy::*member_fu
*** 43,49 ****
  #ifdef BOOST_HAS_LONG_LONG
  #define BOOST_TT_ALIGNMENT_BASE_TYPES BOOST_PP_TUPLE_TO_LIST( \
          12, ( \
! char, short, int, long, long long, float, double, long double \
          , void*, function_ptr, member_ptr, member_function_ptr))
  #else
  #define BOOST_TT_ALIGNMENT_BASE_TYPES BOOST_PP_TUPLE_TO_LIST( \
--- 44,50 ----
  #ifdef BOOST_HAS_LONG_LONG
  #define BOOST_TT_ALIGNMENT_BASE_TYPES BOOST_PP_TUPLE_TO_LIST( \
          12, ( \
! char, short, int, long, longlong, float, double, long double \
          , void*, function_ptr, member_ptr, member_function_ptr))
  #else
  #define BOOST_TT_ALIGNMENT_BASE_TYPES BOOST_PP_TUPLE_TO_LIST( \


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk