Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Uncle Steve Newsgroups: comp.lang.c Subject: Re: Types in C Date: Mon, 23 May 2011 21:10:54 -0400 Organization: Friends of the Galactic Collective Lines: 40 Message-ID: <5e3bc1901a4e1d6-bdea9@gmail.com> References: <43d4ef5f7d2b0f9-0f635@gmail.com> <848fd4a481072a3-7a4d3@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit Injection-Info: mx04.eternal-september.org; posting-host="job9yP/rmK/fxQbJrcqEcA"; logging-data="5829"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ZxJJEG1dR7vfbFKEFen0o" User-Agent: nn 6.7.3 Content-Length: 1536 Cancel-Lock: sha1:DjUuj8pXvAZ8TNkxVZl1EJcFUns= Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:4642 On Mon, May 23, 2011 at 11:57:11PM +0000, Seebs wrote: > On 2011-05-23, Uncle Steve wrote: > > Um, no. I care about the "size" of a type so I don't misuse it in the > > program. If a counter rolls over because I assumed an int was 32 bits > > wide, that's a problem. If I use an int type of known size, I'll be > > much less likely to run into that problem. > > You're doing it wrong. Maybe. > Don't know the size. Know the *minimum* size. You don't actually need > to know whether something is 32 bits, you just need to know that it's at > least big enough to hold some particular value. For all you know you're > getting a 64-bit type because that's what's fast on this hardware. If I define a variable as a 32-bit integer, by definition I know what its range of values are. If I try to exceed that range, it is programmer error. If I port my code to a different platform, the typedefs for those types will get made so they are consisted with the x86 port, if possible. I don't see how that can be bad. > If you specify a specific type when a less specific type would do, you hurt > performance on a fair variety of hardware. I think platform specific code will (almost?) always be quicker than generalized code that compiles and runs on multiple architectures unmodified. I think you're going to have to show how your logic works on this point. Regards, Uncle Steve -- Should a professional politician be charged with molestation if he kisses babies while attending political rallies?