[Libevent-users] [Patch] Install autoconf header file as evconfig.h

Steven Grimm sgrimm at facebook.com
Fri Feb 16 20:08:03 EST 2007


Dave Gotwisner wrote:
> 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?

You wouldn't, and your application would fail to build because it's not 
compatible with that architecture -- which IMO is a better situation 
than it building just fine (because you used "long") and failing at 
runtime because the code expected a particular length and got something 
different. If the failure is in an infrequently-used part of the code 
you might not discover it until pretty far down the road. Using typedefs 
gives you fail-fast behavior on systems that can't support the required 
types.

> 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.

Me too, and I'm not defending that practice! If anyone sees redundancy 
like that in libevent, it should be stamped out immediately. But the 
fact that word-length typedefs can be used poorly isn't a reason to not 
use them at all; they do serve a useful purpose in some cases.

-Steve


More information about the Libevent-users mailing list