bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug-gnulib] Re: stdint_.h update


From: Jim Meyering
Subject: [bug-gnulib] Re: stdint_.h update
Date: Sat, 14 May 2005 16:37:07 +0200

Hi Bruno,

> 2005-05-13  Bruno Haible  <address@hidden>
>
>       * stdint_.h (int64_t, uint64_t, int_least64_t, uint_least64_t,
>       int_fast64_t, uint_fast64_t, intmax_t, uintmax_t, INT64_MIN, INT64_MAX,
>       UINT64_MAX, INT_LEAST64_MIN, INT_LEAST64_MAX, UINT_LEAST64_MAX,
>       INT_FAST64_MIN, INT_FAST64_MAX, UINT_FAST64_MAX, INTMAX_MIN,
>       INTMAX_MAX, UINTMAX_MAX, INT64_C, UINT64_C, INTMAX_C, UINTMAX_C):
>       Add support for 64-bit integers in the MSVC compiler.

Hmm... I hadn't ever encountered those `i64' and `ui64' suffixes:

>   #define INT64_MIN   (~INT64_MIN)
>   #define INT64_MAX   9223372036854775807LL
>   #define UINT64_MAX 18446744073709551615ULL
> + #elif defined(_MSC_VER)
> + #define INT64_MIN   (~INT64_MIN)
> + #define INT64_MAX   9223372036854775807i64
> + #define UINT64_MAX 18446744073709551615ui64
>   #endif

Then I saw them again in the following macros:

> + #define INT64_C(x) x##i64
> + #define UINT64_C(x) x##ui64
>   #endif

What do you think about using those two macros like this?

  #if @HAVE_LONG_64BIT@
  # define INT64_MIN   (~INT64_MIN)
  # define INT64_MAX   INT64_C(9223372036854775807)
  # define UINT64_MAX UINT64_C(18446744073709551615)
  #elif @HAVE_LONG_LONG_64BIT@
  # define INT64_MIN   (~INT64_MIN)
  # define INT64_MAX   INT64_C(9223372036854775807)
  # define UINT64_MAX UINT64_C(18446744073709551615)
  #elif defined(_MSC_VER)
  # define INT64_MIN   (~INT64_MIN)
  # define INT64_MAX   INT64_C(9223372036854775807)
  # define UINT64_MAX UINT64_C(18446744073709551615)
  #endif

Then, look carefully and you'll see that all three branches
are the same, so you can condense them into one:

  #if @HAVE_LONG_64BIT@ || @HAVE_LONG_LONG_64BIT@ || defined _MSC_VER
  # define INT64_MIN   (~INT64_MIN)
  # define INT64_MAX   INT64_C(9223372036854775807)
  # define UINT64_MAX UINT64_C(18446744073709551615)
  #endif

Jim

P.S. It's easier to read cpp directives when the indentation
after the `#' reflects the nesting level.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]