[comp.sys.att] 3b-1 C language incompatibility?

aramini@apollo.COM (Michael Aramini) (03/14/89)

The C declarations below are compilable by at least 3 different
C compilers, but the 3b-1's C compiler complains that I am trying
to redefine object.  Is "object" a reserved word or predefined in
some other way in the 3b-1 C compiler?  If thats not the problem,
does anyone have any suggestions about what else might be wrong?

struct fixnum {
	char type;
	int count;
	int fix_dat;
};
struct symbol {
	char type;
	struct symbol *next;
	char *pname;
	union object *val;
	union object *plist;
};
struct cons {
	char type;
	int count;
	struct object *car;
	struct object *cdr;
};
union object {
	struct fixnum fix;
	struct symbol sym;
	struct cons cns;
	char type;
};

avr@mtgzy.att.com (a.v.reed) (03/15/89)

In article <4202ad64.c463@apollo.COM>, aramini@apollo.COM (Michael Aramini) writes:
< The C declarations below are compilable by at least 3 different
< C compilers, but the 3b-1's C compiler complains that I am trying
< to redefine object.  Is "object" a reserved word or predefined in
< some other way in the 3b-1 C compiler?  If thats not the problem,
< does anyone have any suggestions about what else might be wrong?
< 
< struct fixnum {
< 	char type;
< 	int count;
< 	int fix_dat;
< };
< struct symbol {
< 	char type;
< 	struct symbol *next;
< 	char *pname;
< 	union object *val;
< 	union object *plist;
< };
< struct cons {
< 	char type;
< 	int count;
< 	struct object *car;
< 	struct object *cdr;
< };
< union object {
< 	struct fixnum fix;
< 	struct symbol sym;
< 	struct cons cns;
< 	char type;
< };

In C, the identifiers of structs and unions share the struct-or-union
identifier space. Code refering to both a struct and a union with the
same identifier is bogus, and the results of trying to compile it are
undefined. (In the future, could you please run your code through lint
before publishing it on the net?)

				Adam Reed (avr@mtgzy.ATT.COM)