[Libevent-users] [Patch] Install autoconf header
file as evconfig.h
Dave Gotwisner
dgotwisner at rosum.com
Fri Feb 16 19:58:53 EST 2007
Steven Grimm wrote:
> Dave Gotwisner wrote:
>
>> I personally hate the proliferation of typedefs. I have seen u8, U8,
>> u_int8, uint8, and many others that all express the same thing.
>> (similarly for 16, 32, and 64 bit sizes).
>
>
> The lack of a common standard is the problem, IMO, not the existence
> of typedefs per se. The underlying problem is that C doesn't provide
> any built-in portable way of saying you want a data type exactly THIS
> big, short of resorting to structs with bit-counted fields. None of
> the built-in types are required to be a particular size, even if they
> happen to have settled down on particular sizes on present-day
> architectures. I would much rather waste one line of header file
> somewhere doing a seemingly redundant typedef than have my code break
> on some future 128-bit machine whose "long" is 64 bits and "long long"
> is 128. (Heck, forget "future" -- such machines exist today!) That
> would be perfectly legal for a C compiler to do. "uint32_t" is much
> more precise and unambiguous than "unsigned long" -- I read that and
> have no doubt how big the author expected the data type to be.
>
> -Steve
>
>
Yes, C doesn't define it (ANSI should have at the char/short/long/long
long level). Even though there is nothing requiring that short is 16
and long is 32, the fact that the type.h files I mentioned in my
previous post imply that they really are required to be these sizes, or
the header files be broke.
If there were an architecture with char being 8, short being 32, long
being 64, and long long being 128 (the National 32032 did this without
the long long), there would be no way to express a 16 bit data type, so
you couldn't even define an uint16_t type! How would autoconf work in
this case? How would you build a types.h for C (not C++) to deal with a
16 bit data type as a native type? How badly would all the code on the
planet that uses a uint16_t type work (assuming you can get it to
compile)? Note, this is because of the limitation on the C standard,
not on the games played by the typedefs.
Using your example, if you had a 8, 16, 64, and 128 bit native types,
and you wanted an EXACTLY 32 bit type, how would it work? Given ANSI
only specifies char, short, long, and long long, when we support 256 bit
native types, and you still need the smaller ones (or everything written
to date will break), how would you get the fifth type?
I have worked on projects where different people are familiar with
different type conventions, so the code is written with two or more of
the various typedefs, based upon who touches the code when. Note that
this is for commercial products not open source, with formal review
processes, etc.
More information about the Libevent-users
mailing list