Jeff Garland wrote:
On Sun, 25 Jul 2004 17:16:38 -0500, Aaron W. LaFramboise wrote
Hi,
As I'm sure you know, long long and unsigned long long are supported
by GCC in C++. However, -std=c++98 (not quite sure why, to be
honest) and -pedantic cause lots of warnings and errors to be
generated in the Boost headers when long long is used. In my
project, it is desirable to use these flags for other reasons, but
the effect these flags have on the Boost headers is decidedly undesirable.
So far, I've been wrapping the Boost headers in forwarding headers that
mark the Boost headers as system headers so that they compile without
warning or error. Is there any disadvantage to doing this?
GCC supports long long even with the above options, but only if
__extension__ is used. I notice that there a Boost-standard 64bit
type, boost::int64_t. Is there some reason that this can't be typedef'ed
using the GCC extension, and then this identifier used in all places
where 'long long' is being used? Are there type system rules that
prevent this, or some other reason?
Is there some particular boost header that is using long long directly?
date_time uses 64 bit types, but it uses boost::int64_t and its friends to be
portable. Or are you saying that just using boost:int64_t is causing the problem?
It is the uses of "long long" instead of int64_t that are causing the
problem.
The following patch is a mechanical change that replaces all uses I
could find into int64_t and uint64_t. It also includes boost/cstdint.h
where necessary. However, this only changes headers. It is not
necessary, in my case, to make changes in lib/, because these are only
compiled by Boost.Build; however, it may be desirable to change these
also for some other reason. I'm not sure about this.
Index: boost/boost/cast.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/cast.hpp,v
retrieving revision 1.21
diff -c -r1.21 cast.hpp
*** boost/boost/cast.hpp 26 Feb 2004 18:26:46 -0000 1.21
--- boost/boost/cast.hpp 26 Jul 2004 03:56:12 -0000
***************
*** 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
{
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
{
BOOST_STATIC_CONSTANT(bool, is_specialized = true);
BOOST_STATIC_CONSTANT(bool, is_signed = true);
! static int64_t max BOOST_PREVENT_MACRO_SUBSTITUTION ()
{
# ifdef LONGLONG_MAX
return LONGLONG_MAX;
***************
*** 170,176 ****
# endif
}
! static long long min BOOST_PREVENT_MACRO_SUBSTITUTION ()
{
# ifdef LONGLONG_MIN
return LONGLONG_MIN;
--- 170,176 ----
# endif
}
! static int64_t min BOOST_PREVENT_MACRO_SUBSTITUTION ()
{
# ifdef LONGLONG_MIN
return LONGLONG_MIN;
***************
*** 181,191 ****
};
template <>
! struct fixed_numeric_limits_base
{
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
{
BOOST_STATIC_CONSTANT(bool, is_specialized = true);
BOOST_STATIC_CONSTANT(bool, is_signed = false);
! static uint64_t max BOOST_PREVENT_MACRO_SUBSTITUTION ()
{
# ifdef ULONGLONG_MAX
return ULONGLONG_MAX;
***************
*** 194,200 ****
# endif
}
! static unsigned long long min
BOOST_PREVENT_MACRO_SUBSTITUTION () { return 0; }
};
# endif
} // namespace detail
--- 194,200 ----
# endif
}
! static uint64_t 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.27
diff -c -r1.27 concept_check.hpp
*** boost/boost/concept_check.hpp 22 Nov 2003 04:51:00 -0000 1.27
--- boost/boost/concept_check.hpp 26 Jul 2004 03:56:14 -0000
***************
*** 17,22 ****
--- 17,23 ----
#define BOOST_CONCEPT_CHECKS_HPP
#include
+ #include
#include
#include
#include <utility>
***************
*** 180,186 ****
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
--- 181,187 ----
template <> struct SignedIntegerConcept<int> { void constraints() {} };
template <> struct SignedIntegerConcept<long> { void constraints() {} };
# if defined(BOOST_HAS_LONG_LONG)
! template <> struct SignedIntegerConcept { void
constraints() {} };
# endif
// etc.
#endif
Index: boost/boost/integer_fwd.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/integer_fwd.hpp,v
retrieving revision 1.2
diff -c -r1.2 integer_fwd.hpp
*** boost/boost/integer_fwd.hpp 27 Dec 2002 16:51:52 -0000 1.2
--- boost/boost/integer_fwd.hpp 26 Jul 2004 03:56:15 -0000
***************
*** 14,21 ****
#include <climits> // for UCHAR_MAX, etc.
#include <cstddef> // for std::size_t
! #include // for BOOST_NO_INTRINSIC_WCHAR_T
! #include // for std::numeric_limits
namespace boost
--- 14,22 ----
#include <climits> // for UCHAR_MAX, etc.
#include <cstddef> // for std::size_t
! #include // for int64_t
! #include // for BOOST_NO_INTRINSIC_WCHAR_T
! #include // for std::numeric_limits
namespace boost
***************
*** 69,78 ****
#ifdef ULLONG_MAX
template < >
! class integer_traits< long long >;
template < >
! class integer_traits< unsigned long long >;
#endif
--- 70,79 ----
#ifdef ULLONG_MAX
template < >
! class integer_traits< int64_t >;
template < >
! class integer_traits< uint64_t >;
#endif
Index: boost/boost/integer_traits.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/integer_traits.hpp,v
retrieving revision 1.23
diff -c -r1.23 integer_traits.hpp
*** boost/boost/integer_traits.hpp 27 Aug 2003 10:30:53 -0000 1.23
--- boost/boost/integer_traits.hpp 26 Jul 2004 03:56:15 -0000
***************
*** 22,27 ****
--- 22,28 ----
#define BOOST_INTEGER_TRAITS_HPP
#include
+ #include
#include
// These are an implementation detail and not part of the interface
***************
*** 159,211 ****
#if defined(ULLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
template<>
! class integer_traits<long long>
! : public std::numeric_limits<long long>,
! public detail::integer_traits_base
{ };
template<>
! class integer_traits<unsigned long long>
! : public std::numeric_limits<unsigned long long>,
! public detail::integer_traits_base
{ };
#elif defined(ULONG_LONG_MAX) && defined(BOOST_HAS_LONG_LONG)
template<>
! class integer_traits<long long> : public std::numeric_limits<long
long>, public detail::integer_traits_base{ };
! template<>
! class integer_traits<unsigned long long>
! : public std::numeric_limits<unsigned long long>,
! public detail::integer_traits_base
{ };
#elif defined(ULONGLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
template<>
! class integer_traits<long long>
! : public std::numeric_limits<long long>,
! public detail::integer_traits_base
{ };
template<>
! class integer_traits<unsigned long long>
! : public std::numeric_limits<unsigned long long>,
! public detail::integer_traits_base
{ };
#elif defined(_LLONG_MAX) && defined(_C2) && defined(BOOST_HAS_LONG_LONG)
template<>
! class integer_traits<long long>
! : public std::numeric_limits<long long>,
! public detail::integer_traits_base
{ };
template<>
! class integer_traits<unsigned long long>
! : public std::numeric_limits<unsigned long long>,
! public detail::integer_traits_base
{ };
#endif
--- 160,214 ----
#if defined(ULLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
template<>
! class integer_traits
! : public std::numeric_limits,
! public detail::integer_traits_base
{ };
template<>
! class integer_traits
! : public std::numeric_limits,
! public detail::integer_traits_base
{ };
#elif defined(ULONG_LONG_MAX) && defined(BOOST_HAS_LONG_LONG)
template<>
! class integer_traits : public std::numeric_limits,
! public
! detail::integer_traits_base{ };
! template<>
! class integer_traits
! : public std::numeric_limits,
! public detail::integer_traits_base
{ };
#elif defined(ULONGLONG_MAX) && defined(BOOST_HAS_LONG_LONG)
template<>
! class integer_traits
! : public std::numeric_limits,
! public detail::integer_traits_base
{ };
template<>
! class integer_traits
! : public std::numeric_limits,
! public detail::integer_traits_base
{ };
#elif defined(_LLONG_MAX) && defined(_C2) && defined(BOOST_HAS_LONG_LONG)
template<>
! class integer_traits
! : public std::numeric_limits,
! public detail::integer_traits_base
{ };
template<>
! class integer_traits
! : public std::numeric_limits,
! public detail::integer_traits_base
{ };
#endif
Index: boost/boost/limits.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/limits.hpp,v
retrieving revision 1.10
diff -c -r1.10 limits.hpp
*** boost/boost/limits.hpp 28 Feb 2004 21:02:02 -0000 1.10
--- boost/boost/limits.hpp 26 Jul 2004 03:56:16 -0000
***************
*** 12,17 ****
--- 12,18 ----
#define BOOST_LIMITS
#include
+ #include
#ifdef BOOST_NO_LIMITS
# include
***************
*** 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 int64_t
#endif
namespace std
Index: boost/boost/iterator/counting_iterator.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/iterator/counting_iterator.hpp,v
retrieving revision 1.4
diff -c -r1.4 counting_iterator.hpp
*** boost/boost/iterator/counting_iterator.hpp 1 Feb 2004 22:11:47 -0000 1.4
--- boost/boost/iterator/counting_iterator.hpp 26 Jul 2004 03:56:18 -0000
***************
*** 6,11 ****
--- 6,12 ----
#ifndef COUNTING_ITERATOR_DWA200348_HPP
# define COUNTING_ITERATOR_DWA200348_HPP
+ # include
# include
# include
# include
***************
*** 58,68 ****
# if defined(BOOST_HAS_LONG_LONG)
template <>
! struct is_numeric<long long>
: mpl::true_ {};
template <>
! struct is_numeric<unsigned long long>
: mpl::true_ {};
# endif
--- 59,69 ----
# if defined(BOOST_HAS_LONG_LONG)
template <>
! struct is_numeric
: mpl::true_ {};
template <>
! struct is_numeric
: 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 -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 26 Jul
2004 03:56:22 -0000
***************
*** 19,31 ****
#error This header only works on PPC CPUs.
#endif
namespace boost {
namespace numeric {
namespace interval_lib {
namespace detail {
typedef union {
! long long int imode;
double dmode;
} rounding_mode_struct;
--- 19,33 ----
#error This header only works on PPC CPUs.
#endif
+ #include
+
namespace boost {
namespace numeric {
namespace interval_lib {
namespace detail {
typedef union {
! int64_t 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.14
diff -c -r1.14 type_id.hpp
*** boost/boost/python/type_id.hpp 12 Mar 2004 18:43:08 -0000 1.14
--- boost/boost/python/type_id.hpp 26 Jul 2004 03:56:24 -0000
***************
*** 6,11 ****
--- 6,13 ----
#ifndef TYPE_ID_DWA2002517_HPP
# define TYPE_ID_DWA2002517_HPP
+ # include
+
# include
# include
***************
*** 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(long long)
# endif
# undef BOOST_PYTHON_SIGNED_INTEGRAL_TYPE_ID
# endif
--- 103,109 ----
// 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(int64_t)
# 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.17
diff -c -r1.17 wrap_python.hpp
*** boost/boost/python/detail/wrap_python.hpp 1 May 2003 05:19:47 -0000 1.17
--- boost/boost/python/detail/wrap_python.hpp 26 Jul 2004 03:56:25 -0000
***************
*** 24,29 ****
--- 24,30 ----
// Python's LongObject.h helpfully #defines ULONGLONG_MAX for us,
// which confuses Boost's config
//
+ #include
#include
#ifndef ULONG_MAX
# define BOOST_PYTHON_ULONG_MAX_UNDEFINED
***************
*** 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 int64_t
# 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.6
diff -c -r1.6 operators.hpp
*** boost/boost/spirit/phoenix/operators.hpp 9 Jul 2004 08:28:05 -0000 1.6
--- boost/boost/spirit/phoenix/operators.hpp 26 Jul 2004 03:56:32 -0000
***************
*** 23,28 ****
--- 23,29 ----
#include
#include
#include
+ #include
///////////////////////////////////////////////////////////////////////////////
namespace phoenix {
***************
*** 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 { static int const value =
110; };
! template <> struct rank { 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 -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 26 Jul 2004 03:56:32 -0000
***************
*** 11,16 ****
--- 11,17 ----
#define BOOST_SPIRIT_CHSET_HPP
///////////////////////////////////////////////////////////////////////////////
+ #include
#include
#include
#include
***************
*** 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
! chset_p(int64_t ch)
! { return chset(ch); }
//////////////////////////////////
! inline chset
! chset_p(uint64_t ch)
! { return chset(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 -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 26 Jul 2004 03:56:33 -0000
***************
*** 12,17 ****
--- 12,18 ----
#ifndef BOOST_TT_IS_CONVERTIBLE_HPP_INCLUDED
#define BOOST_TT_IS_CONVERTIBLE_HPP_INCLUDED
+ #include "boost/cstdint.hpp"
#include "boost/type_traits/detail/yes_no_type.hpp"
#include "boost/type_traits/config.hpp"
#include "boost/type_traits/is_array.hpp"
***************
*** 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) \
--- 261,267 ----
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,int64_t) \
/**/
# 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 -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 26 Jul 2004 03:56:34 -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"
***************
*** 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,uint64_t,true)
! BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_integral,int64_t,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 -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 26 Jul 2004 03:56:34
-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"
***************
*** 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, int64_t, float, double, long double \
, void*, function_ptr, member_ptr, member_function_ptr))
#else
#define BOOST_TT_ALIGNMENT_BASE_TYPES BOOST_PP_TUPLE_TO_LIST( \