This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Another bit of ISO C conversion...
- From: "Zack Weinberg" <zack at codesourcery dot com>
- To: gcc at gcc dot gnu dot org
- Date: Sun, 07 Dec 2003 16:27:14 -0800
- Subject: Another bit of ISO C conversion...
We've had a lot of people put in time to convert GCC to ISO C style,
and I want to say that I appreciate all of that effort. There's one
transformation that hasn't been getting done, though: use of #elif.
K&R C didn't have this directive so we have lots of nested #if
blocks. For example, from hwint.h:
#if HOST_BITS_PER_LONG >= 64 || !defined NEED_64BIT_HOST_WIDE_INT
# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG
# define HOST_WIDE_INT long
#else
# if HOST_BITS_PER_LONGLONG >= 64
# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONGLONG
# define HOST_WIDE_INT long long
# else
# if HOST_BITS_PER___INT64 >= 64
# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER___INT64
# define HOST_WIDE_INT __int64
# else
#error "Unable to find a suitable type for HOST_WIDE_INT"
# endif
# endif
#endif
This can become
#if HOST_BITS_PER_LONG >= 64 || !defined NEED_64BIT_HOST_WIDE_INT
# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONG
# define HOST_WIDE_INT long
#elif HOST_BITS_PER_LONGLONG >= 64
# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER_LONGLONG
# define HOST_WIDE_INT long long
#elif HOST_BITS_PER___INT64 >= 64
# define HOST_BITS_PER_WIDE_INT HOST_BITS_PER___INT64
# define HOST_WIDE_INT __int64
#else
# error "Unable to find a suitable type for HOST_WIDE_INT"
#endif
which is simpler, easier to read, and easier to modify.
Note also that it is no longer necessary to indent the leading # of
an #error directive; or, turnabout, it is no longer necessary to write
the leading # of any directive in column 1, so this becomes a style
decision.
zw