Added new types boost::long_long_type and boost::ulong_long_type in boost/config.hpp and applied these types in place of "long long" throughout. As a result, almost all of boost now compiles cleanly with -ansi -pedantic with gcc. Changes tested with gcc 3.3, 2.95, VC7.1 and Intel 8.

[SVN r24899]
This commit is contained in:
John Maddock
2004-09-04 10:34:49 +00:00
parent 6bf226144f
commit 64a8b36b23
6 changed files with 59 additions and 22 deletions

View File

@ -399,6 +399,21 @@ namespace std {
# define BOOST_DEDUCED_TYPENAME # define BOOST_DEDUCED_TYPENAME
#endif #endif
// long long workaround ------------------------------------------//
// On gcc (and maybe other compilers?) long long is alway supported
// but it's use may generate either warnings (with -ansi), or errors
// (with -pedantic -ansi) unless it's use is prefixed by __extension__
//
namespace boost{
#ifdef __GNUC__
__extension__ typedef long long long_long_type;
__extension__ typedef unsigned long long ulong_long_type;
#else
typedef long long long_long_type;
typedef unsigned long long ulong_long_type;
#endif
}
// BOOST_[APPEND_]EXPLICIT_TEMPLATE_[NON_]TYPE macros --------------------------// // BOOST_[APPEND_]EXPLICIT_TEMPLATE_[NON_]TYPE macros --------------------------//
// //
// Some compilers have problems with function templates whose // Some compilers have problems with function templates whose

View File

@ -24,8 +24,10 @@
// Add missing specializations for numeric_limits: // Add missing specializations for numeric_limits:
#ifdef BOOST_HAS_MS_INT64 #ifdef BOOST_HAS_MS_INT64
# define BOOST_LLT __int64 # define BOOST_LLT __int64
# define BOOST_ULLT unsigned __int64
#else #else
# define BOOST_LLT long long # define BOOST_LLT ::boost::long_long_type
# define BOOST_ULLT ::boost::ulong_long_type
#endif #endif
namespace std namespace std
@ -84,23 +86,23 @@ namespace std
}; };
template<> template<>
class numeric_limits<unsigned BOOST_LLT> class numeric_limits<BOOST_ULLT>
{ {
public: public:
BOOST_STATIC_CONSTANT(bool, is_specialized = true); BOOST_STATIC_CONSTANT(bool, is_specialized = true);
#ifdef BOOST_HAS_MS_INT64 #ifdef BOOST_HAS_MS_INT64
static unsigned BOOST_LLT min BOOST_PREVENT_MACRO_SUBSTITUTION (){ return 0ui64; } static BOOST_ULLT min BOOST_PREVENT_MACRO_SUBSTITUTION (){ return 0ui64; }
static unsigned BOOST_LLT max BOOST_PREVENT_MACRO_SUBSTITUTION (){ return 0xFFFFFFFFFFFFFFFFui64; } static BOOST_ULLT max BOOST_PREVENT_MACRO_SUBSTITUTION (){ return 0xFFFFFFFFFFFFFFFFui64; }
#elif defined(ULLONG_MAX) && defined(ULLONG_MIN) #elif defined(ULLONG_MAX) && defined(ULLONG_MIN)
static unsigned BOOST_LLT min BOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULLONG_MIN; } static BOOST_ULLT min BOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULLONG_MIN; }
static unsigned BOOST_LLT max BOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULLONG_MAX; } static BOOST_ULLT max BOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULLONG_MAX; }
#elif defined(ULONGLONG_MAX) && defined(ULONGLONG_MIN) #elif defined(ULONGLONG_MAX) && defined(ULONGLONG_MIN)
static unsigned BOOST_LLT min BOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULONGLONG_MIN; } static BOOST_ULLT min BOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULONGLONG_MIN; }
static unsigned BOOST_LLT max BOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULONGLONG_MAX; } static BOOST_ULLT max BOOST_PREVENT_MACRO_SUBSTITUTION (){ return ULONGLONG_MAX; }
#else #else
static unsigned BOOST_LLT min BOOST_PREVENT_MACRO_SUBSTITUTION (){ return 0uLL; } static BOOST_ULLT min BOOST_PREVENT_MACRO_SUBSTITUTION (){ return 0uLL; }
static unsigned BOOST_LLT max BOOST_PREVENT_MACRO_SUBSTITUTION (){ return ~0uLL; } static BOOST_ULLT max BOOST_PREVENT_MACRO_SUBSTITUTION (){ return ~0uLL; }
#endif #endif
BOOST_STATIC_CONSTANT(int, digits = sizeof(BOOST_LLT) * CHAR_BIT); BOOST_STATIC_CONSTANT(int, digits = sizeof(BOOST_LLT) * CHAR_BIT);
BOOST_STATIC_CONSTANT(int, digits10 = (CHAR_BIT * sizeof (BOOST_LLT)) * 301L / 1000); BOOST_STATIC_CONSTANT(int, digits10 = (CHAR_BIT * sizeof (BOOST_LLT)) * 301L / 1000);
@ -108,8 +110,8 @@ namespace std
BOOST_STATIC_CONSTANT(bool, is_integer = true); BOOST_STATIC_CONSTANT(bool, is_integer = true);
BOOST_STATIC_CONSTANT(bool, is_exact = true); BOOST_STATIC_CONSTANT(bool, is_exact = true);
BOOST_STATIC_CONSTANT(int, radix = 2); BOOST_STATIC_CONSTANT(int, radix = 2);
static unsigned BOOST_LLT epsilon() throw() { return 0; }; static BOOST_ULLT epsilon() throw() { return 0; };
static unsigned BOOST_LLT round_error() throw() { return 0; }; static BOOST_ULLT round_error() throw() { return 0; };
BOOST_STATIC_CONSTANT(int, min_exponent = 0); BOOST_STATIC_CONSTANT(int, min_exponent = 0);
BOOST_STATIC_CONSTANT(int, min_exponent10 = 0); BOOST_STATIC_CONSTANT(int, min_exponent10 = 0);
@ -121,10 +123,10 @@ namespace std
BOOST_STATIC_CONSTANT(bool, has_signaling_NaN = false); BOOST_STATIC_CONSTANT(bool, has_signaling_NaN = false);
BOOST_STATIC_CONSTANT(bool, has_denorm = false); BOOST_STATIC_CONSTANT(bool, has_denorm = false);
BOOST_STATIC_CONSTANT(bool, has_denorm_loss = false); BOOST_STATIC_CONSTANT(bool, has_denorm_loss = false);
static unsigned BOOST_LLT infinity() throw() { return 0; }; static BOOST_ULLT infinity() throw() { return 0; };
static unsigned BOOST_LLT quiet_NaN() throw() { return 0; }; static BOOST_ULLT quiet_NaN() throw() { return 0; };
static unsigned BOOST_LLT signaling_NaN() throw() { return 0; }; static BOOST_ULLT signaling_NaN() throw() { return 0; };
static unsigned BOOST_LLT denorm_min() throw() { return 0; }; static BOOST_ULLT denorm_min() throw() { return 0; };
BOOST_STATIC_CONSTANT(bool, is_iec559 = false); BOOST_STATIC_CONSTANT(bool, is_iec559 = false);
BOOST_STATIC_CONSTANT(bool, is_bounded = false); BOOST_STATIC_CONSTANT(bool, is_bounded = false);

View File

@ -16,8 +16,13 @@ namespace boost_has_long_long{
int test() int test()
{ {
#ifdef __GNUC__
__extension__ long long lli = 0LL;
__extension__ unsigned long long ulli = 0uLL;
#else
long long lli = 0LL; long long lli = 0LL;
unsigned long long ulli = 0uLL; unsigned long long ulli = 0uLL;
#endif
(void)&lli; (void)&lli;
(void)&ulli; (void)&ulli;
return 0; return 0;

View File

@ -23,11 +23,20 @@ struct llt
enum{ value = m }; enum{ value = m };
}; };
#else #else
#ifdef __GNUC__
__extension__
#endif
static const unsigned long long mask = 1uLL << 50; static const unsigned long long mask = 1uLL << 50;
#ifdef __GNUC__
__extension__
#endif
template <unsigned long long m> template <unsigned long long m>
struct llt struct llt
{ {
#ifdef __GNUC__
__extension__
#endif
static const unsigned long long value = m; static const unsigned long long value = m;
}; };
#endif #endif

View File

@ -16,8 +16,16 @@ namespace boost_no_long_long_numeric_limits{
int test() int test()
{ {
if(0 == std::numeric_limits<long long>::is_specialized) return -1; #ifdef __GNUC__
if(0 == std::numeric_limits<unsigned long long>::is_specialized) return -1; __extension__
#endif
typedef long long llt;
#ifdef __GNUC__
__extension__
#endif
typedef unsigned long long ullt;
if(0 == std::numeric_limits<llt>::is_specialized) return -1;
if(0 == std::numeric_limits<ullt>::is_specialized) return -1;
return 0; return 0;
} }

View File

@ -170,10 +170,8 @@ int test_main(int, char*[])
typedef unsigned long unsigned_long; typedef unsigned long unsigned_long;
test_integral_limits(unsigned_long(), "unsigned long"); test_integral_limits(unsigned_long(), "unsigned long");
#if defined(BOOST_HAS_LONG_LONG) #if defined(BOOST_HAS_LONG_LONG)
typedef long long long_long; test_integral_limits(::boost::long_long_type(), "long long");
test_integral_limits(long_long(), "long long"); test_integral_limits(::boost::ulong_long_type(), "unsigned long long");
typedef unsigned long long unsigned_long_long;
test_integral_limits(unsigned_long_long(), "unsigned long long");
#endif #endif
#ifdef BOOST_HAS_MS_INT64 #ifdef BOOST_HAS_MS_INT64
typedef __int64 long_long2; typedef __int64 long_long2;