Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.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 19:23:39 -0400 Organization: Friends of the Galactic Collective Lines: 58 Message-ID: References: <43d4ef5f7d2b0f9-0f635@gmail.com> <9401m9Ft2pU9@mid.individual.net> <50d915539d62563-19304@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="10503"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18qbvT3uTjOV6KV8w/kwknv" User-Agent: nn 6.7.3 Content-Length: 2209 Cancel-Lock: sha1:JxCq0YRrNMoO/6BDjeb3es8fpvw= Xref: x330-a1.tempe.blueboxinc.net comp.lang.c:4626 On Mon, May 23, 2011 at 10:24:31PM +0000, Seebs wrote: > On 2011-05-23, Uncle Steve wrote: > > There are no "user defined" types in C. > > Sure there are! Oh, no there aren't! > > Structures and unions are > > aggregates of basic types (and structures/unions). > > Sure. > > So? Doesn't make them not types. Pointers, arrays, enums, structs, > unions... all types. Structs and unions are user-defined. And they are > types. This makes them... *drumroll* user-defined types. Not if we make a finer distinction between types. As I see it there are two types of types: char, int, long, float, void *, etc. are /basic types/ fundamental to the implementation of the C language (and arithmetic operations). Compound types are aggregates of these basic types as well as compound types. There's a fundamental difference you are ignoring given a sufficient vague definition of 'type'. A real user-defined type would be something new like the complex numbers extension in gcc. I don't do much OOP, but someone here probably knows of a language that allows new fundamental type definitions without direct compiler support. C requires compiler support for this. So, if you want a 128-byte integer type either you modify the compiler to emulate arithmetic operations with smaller asm instructions, or you write a library to handle it. > > 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. > > I would guess that one of the times to use macros is "when you have to > be portable to compilers that don't have inline functions". That's > definitely a key application. gmp is well into version 4; I doubt it would compile where there is no support for inline functions, but I have not verified this. Regards, Uncle Steve -- Should a professional politician be charged with molestation if he kisses babies while attending political rallies?