Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!ucbvax!NRCM3.NRC.CA!SERRER From: SERRER@NRCM3.NRC.CA (Martin Serrer) Newsgroups: comp.sys.sgi Subject: cc compiler warning question. Message-ID: <032D013E619F0000A3@NRCNET.NRC.CA> Date: 16 Nov 90 18:54:00 GMT Sender: daemon@ucbvax.BERKELEY.EDU Organization: The Internet Lines: 49 Hello c'ers, I am trying to define and access a data structure 'zero' which contains an array of structures 'one' , the size of which is not know until run time. No problem right? When I compile this code I get warnings about 'illegal zero sized structure member'. The code runs properly but I'm worried about the warnings. What rules am I breaking?? (see the evidence below) Please be gentle as I am still learning about c. Thanks in advance... Martin BTW. this is on a 4D50/GT IRIX 3.2 -------------------------------evidence----------------------------------------- % cat t.c #include typedef struct { int a; int b; } TINY; typedef struct { TINY two; int c; } SMALL; typedef struct { SMALL *one[]; int f; } BIG; BIG *zero; main() { zero = (BIG *) malloc( (sizeof(BIG) + sizeof(SMALL) * 2) ); zero->f = 1; zero->one[0].c = 2; printf("--- %i\n",zero->f); printf("--- %i\n",zero->one[0].c); } % cc t.c ccom: Warning: t.c, line 18: illegal zero sized structure member: one } BIG; --^ ccom: Warning: t.c, line 28: struct/union or struct/union pointer required zero->one[0].c = 2; ---------------^ ccom: Warning: t.c, line 29: struct/union or struct/union pointer required printf("--- %i\n",zero->one[0].c); -------------------------------^ % t --- 1 --- 2 +-----------------------------------------------------------------------------+ | Martin Serrer Systems Lab., Bldg. M2, Montreal Rd.| | 613-993-9442 National Research Council of Canada,| | serrer@syslab.nrc.ca Ottawa, Ontario, Canada K1A-0R6 | +------------------- Software Rusts, Rust never Sleeps -----------------------+