On Sat, 23 Feb 2002 20:10:53 -0800, Brent Dax <[EMAIL PROTECTED]> wrote: > Dan Sugalski: > # At 10:43 PM -0500 2/23/02, Josh Wilmes wrote: > # >So indent needs to be told about non-standard type > # (typedefs) to work best. > # >The problem is that some of the parrot code does this: > # > > # >#define CHARTYPE struct parrot_chartype_t > # >#define ENCODING struct parrot_encoding_t > # >#define STRING struct parrot_string_t > # >#define Parrot_CharType struct parrot_chartype_t * > # >#define Parrot_Encoding struct parrot_encoding_t * > # >#define Parrot_String struct parrot_string_t *
> # We should make the first three typedefs. (Well, OK, we should make > # them all typedefs) I thought they were already, which'd explain some > # of the interesting error messages I get at times. > > struct foo_t { > int i; > }; > > typedef struct foo_t * FooPtr; > typedef struct foo_t FOO; > > void bar(FooPtr); > > void bar(FOO *x) { > x->i++; > } > > int main() { > FOO* x=malloc(sizeof(struct foo_t)); > > x->i = -1; > > bar(x); > > return x->i; > } > > VC++ doesn't like stunts like that. That's why I changed it to #define > the types instead. Assuming that VC++ whinges about the "difference" between the prototype of bar() and the definition? If VC++ exits with an error, it is wrong. If it warns about this it is complaining about nothing. Both the C99 and C89/90 standards require this to work. A typedef does not introduce a new type, but just an alias to another type. Objects of the typedef'ed type and of the original type are compatible. I'd look for the compiler flag in VC++ that turns of these whinges, rather than not use features of the language in the way they should be used, simply because one compiler doesn't do the right thing. Even lclint -strict doesn't complain about the prototypes above, and that's notoriously hard to satisfy (of course it complains about quite a few other things in the code above, but that's a separate issue) Martien -- | Martien Verbruggen | Freudian slip: when you say one Trading Post Australia Pty Ltd | thing but mean your mother. |