This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] fix gdb.base/remote.c for small int targets
On Aug 31, 10:25am, Eli Zaretskii wrote:
> > +#if INT_MAX < 32768
>
> Shouldn't you use 32768L or 32768U? If an int is only 16 bits wide,
> 32768 might overflow into the sign bit, and then all bets are off.
Although not incorrect, using 32768L or 32768U is not necessary.
According to section 7.11.1 of Harbison and Steele:
Preprocessor constant expressions must be evaluated at compile
time, and are subject to some relatively strict constraints. Such
expressions must have integral type, and can involve only integer
constants, character constants, and the special defined operator.
All arithmetic is to be done using types long or unsigned long, as
appropriate to the signedness of the operands, which frees the
preprocessor from having to deal with several sizes of integer
types.
Kevin