Enumerated types

Anthony Lapadula al712 at unh.UUCP
Thu May 4 11:19:42 AEST 1989


Are you allowed to 'forward reference' enumerated types?  In other
words, is this legal?

	enum a b;		/* 'enum a' is not yet defined */

Does 'b' end up as an int, or is this an error?


Also, how about this?

	char *ptr;
	enum a { b };		/* 'b' has value 0 in expressions, right? */

	if (ptr == b)		/* Same as (ptr == NULL) ? */
		foo();

(I don't have a copy of the ANSI C Draft for reference, and I
was born and bred under K&R I.)


Thanks,

Anthony Lapadula              ..uunet!unh!al712



More information about the Comp.lang.c mailing list