This is the mail archive of the
mailing list for the GCC project.
Re: Patch: Re: glimits.h is not compatible with -traditional
- To: rth at cygnus dot com (Richard Henderson)
- Subject: Re: Patch: Re: glimits.h is not compatible with -traditional
- From: "John David Anglin" <dave at hiauly1 dot hia dot nrc dot ca>
- Date: Sat, 2 Sep 2000 02:19:49 -0400 (EDT)
- Cc: aoliva at redhat dot com, ghazi at caip dot rutgers dot edu, gcc-bugs at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
> > > +#ifdef __STDC__
> > > #define UINT_MAX (INT_MAX * 2U + 1)
> > > +#else
> > > +#define UINT_MAX ((unsigned)INT_MAX * 2 + 1)
> > > +#endif
> I think you'll just have to ignore this warning. There is no
> correct solution, as far as I can see.
I did some more testing. The current header works because `gcc -traditional'
doesn't reject the `U' suffix, or even warn about it. The warning only
appears if `-traditional' isn't specified.
I am not concerned about the warning itself, although it is bogus if
the define is wrapped in a `#ifdef __STDC__'.
As I understand it, there is no way to define unsigned constants that
are usable in cpp expressions under traditional C when faced with the
2's compliment limit (ie, all comparisons in cpp expressions are signed).
The above macro evaluates to the correct unsigned value but can't be used
in cpp expressions because it is not a valid cpp constant.
HP-UX 10.20 defines UINT_MAX and ULONG_MAX to be 4294967295. Ultrix 4.3
defines them as ((unsigned)4294967295). Both of these are obviously
for 32 bit machines. The ultrix definition has the same problem as
the one above. The unsigned cast could be removed as in the HP define.
#define UINT_MAX (INT_MAX * 2 + 1)
#define ULONG_MAX (LONG_MAX * 2 + 1)
On machines where int and long are the same, both are equivalent to -1
and only equality comparisons work. On 64 bit machines, this only applies
to ULONG_MAX. Within C itself, the `U' defines need a cast. Is this the
J. David Anglin firstname.lastname@example.org
National Research Council of Canada (613) 990-0752 (FAX: 952-6605)