home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16996 < prev    next >
Encoding:
Internet Message Format  |  1992-11-22  |  1.6 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!usc!srhqla!quest!kdq
  2. From: kdq@quest.UUCP (Kevin D. Quitt)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Is this ANSI?
  5. Message-ID: <JTqNuB1w165w@quest.UUCP>
  6. Date: Sun, 22 Nov 92 12:30:30 PST
  7. References: <1992Nov21.125038.26244@sq.sq.com>
  8. Reply-To: srhqla!quest!kdq
  9. Organization: Job quest  (805) 251-8210,  So Cal: (800) 400-8210
  10. Lines: 34
  11.  
  12. >>>struct FM
  13. >>>{
  14. >>>    short    data_len;
  15. >>>    char    data[];        /*  This line is the kicker  */
  16. >>>};
  17.  
  18.     My apologies for asking a question and not being around for the
  19. discussion; my upstream site dropped two days of news and mail on the
  20. floor.  There is a legitimate reason for using the data field of the
  21. above struct: it's a handle for the data that follows the header.
  22.  
  23.     The actual header consists of a number of items, including a data
  24. count which can be 0 or more.  The data is arriving via a tcp socket,
  25. so short of outrageous timeouts, we need some way to know when
  26. everything has arrived.  The header structure is fixed size, and the
  27. data that follow is one of several different structures, or free form
  28. data (for being transmitted to other processes).
  29.  
  30.     The data field of FM lets me write code like:
  31.  
  32.     struct s1 *s1p    = FM.data;
  33.  
  34. instead of
  35.  
  36.     struct s1 *s1p    = (struct s1 *)((char *)&FM + sizeof(struct FM));
  37.  
  38.     From the one article I did see, it appears that ANSI allows this
  39. usage of null arrays, but does not require it.  Too bad.  Well, I'll
  40. know for sure Tuesday, when I get my copy of the (old) ANSI document;
  41. at $184 including shipping and tax, it's cheap at half the price.
  42.  
  43.  
  44.  _
  45. Kevin D. Quitt      96.37% of all statistics are made up.     srhqla!quest!kdq
  46.