Need help with gcc constructors

Dave Brennan brennan at rtp.dg.com
Mon Jan 22 03:46:18 AEST 1990


In the following code segment, I don't understand why gcc complains
"invalid lvalue in unary `&'" about the "trash" initilization but has no
problem with the "junk" initialization.  I invoked the compiler 
"gcc -g -c trial.c"   Can somebody enlighten me here?  Thanks.


typedef enum { 
  enum_1,     
  enum_2   
} tag_t;

typedef struct {
  tag_t type;
  char *class_data;
} BAZ_T;

extern int foo();
extern char *bar;

main()
{
  char *junk = (char *) & (BAZ_T) { enum_1, (char *) foo };
  char *trash = (char *) & (BAZ_T) { enum_2, (char *) bar };
}
--
                                                   _________
Dave Brennan, User Interfaces, Data General Corp. /      brennan at dg-rtp.dg.com 
Research Triangle Park, North Carolina, 27709    /  ...mcnc!rti!dg-rtp!brennan
Hm: (919) 460-5725  Wk: (919) 248-6330 _________/ dave_brennan at rpitsmts.bitnet



More information about the Comp.lang.c mailing list