Subject: Re: rpcgen fix for -fshort-enums
From: David Laight <email@example.com>
Date: 02/05/2002 09:36:23
Ben Harris wrote:
> If (as is looking likely) NetBSD goes to -fshort-enums by default, it'd be
> nice if those enums that are generated by rpcgen were protected from
> causing ABI changes. This patch arranges that by adding extra elements to
> each such enum so as to ensure that it's large enough to hold all the
> legal values of an XDR enum (32-bit signed integer). Does this seem
> sensible? Should asn1_compile do something similar?
These would be needed for big-endian short-enum systems anyway!
> + f_print(fout, "\t__rpcgen_%s_min = -0x7fffffff-1,\n", name);
> + f_print(fout, "\t__rpcgen_%s_max = 0x7fffffff,\n", name);
So maybe they should be present for all ports!
Maybe you should use the 'standard' constants, something like INT32_MAX
- but I can't find the reference to the C spec again!
If you want the generated code to be completely portable (to systems
that aren't 2's compliment) -0x7fffffff-1 is problematical! Since -1
do, maybe -0x7ffffff is -ve enough...