Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!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 17:53:24 -0400 Organization: Friends of the Galactic Collective Lines: 58 Message-ID: <50d915539d62563-19304@gmail.com> References: <0.19dd82b3beedde195878.20110522230329BST.87mxieo0jy.fsf@bsb.me.uk> <43d4ef5f7d2b0f9-0f635@gmail.com> <9401m9Ft2pU9@mid.individual.net> 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="6202"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX188lRq8mAn/bVxy0qFgh1JQ" User-Agent: nn 6.7.3 Content-Length: 2472 Cancel-Lock: sha1:oM9z3tOBd3JOgmsZN0xRoVkadlE= Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:4606 On Tue, May 24, 2011 at 09:25:29AM +1200, Ian Collins wrote: > On 05/24/11 08:51 AM, Uncle Steve wrote: > >On Mon, May 23, 2011 at 07:45:24PM +0000, Seebs wrote: > >>On 2011-05-23, Keith Thompson wrote: > >>>Just a quibble: size_t may be exactly the same type as unsigned long, > >>>since a typedef merely creates an alias for an existing type, not > >>>a new and distinct type. plain char and signed char (for example) > >>>are distinct in a way that size_t and unsigned long (for example) > >>>are not. > >> > >>True. Although, possibly confusingly, there are places where it seems > >>that the thing a typedef creates is itself then called "a type". The > >>wording is a bit fuzzy. > >> > >>We all know what we mean, I think. You could say it several ways: > >> > >> Typedef does not actually create types; instead, it creates > >> names which refer to existing types. > >> > >> Typedef creates types, but those types are identical to existing > >> types and can be used interchangably with them. > > > >How about the idea that typedefs create aliases for the basic built-in > >types supplied by the language spec.? > > A typedef may provide an alias to any existing type, built-in, user > defined or even incomplete. There are no "user defined" types in C. Structures and unions are aggregates of basic types (and structures/unions). I believe incomplete types are a (usually temporary) artifact of the compilation process and you won't ever see them in a running program. Correct me if I'm wrong, but I've never heard of a C compiler that allows you to define something like a BCD integer type when the compiler has no built-in support for it. This is reasonable since the compiler can only generate arithmetic code for types it 'understands'. If you invent your own arithmetic type (as they do in the gmp library) the compiler 'sees' it as opaque binary data, and arithmetic operations are carried out with ... macros and function calls. BTW, have a look at the gmp.h header and note that they do not shy away from macro-like functions. Not that I care a whole lot, but I'd say the writers of the gmp library probably know more than you do about the suitability of inline functions versus macros and when to use each. Just a 'feeling' on the matter, which is not to say that you're entirely wrong. Regards, Uncle Steve -- Should a professional politician be charged with molestation if he kisses babies while attending political rallies?