home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16768 < prev    next >
Encoding:
Text File  |  1992-11-18  |  1.5 KB  |  51 lines

  1. Path: sparky!uunet!ornl!rsg1.er.usgs.gov!darwin.sura.net!zaphod.mps.ohio-state.edu!usc!srhqla!quest!kdq
  2. From: kdq@quest.UUCP (Kevin D. Quitt)
  3. Newsgroups: comp.lang.c
  4. Subject: Is this ANSI?
  5. Message-ID: <9eRguB1w165w@quest.UUCP>
  6. Date: Wed, 18 Nov 92 18:00:19 PST
  7. Reply-To: srhqla!quest!kdq
  8. Organization: Job quest  (805) 251-8210,  So Cal: (800) 400-8210
  9. Lines: 40
  10.  
  11.     I'm working on an HP9000, in UNIX, using the native C compiler
  12. which claims to be ANSI compliant.  It appears to be, in most things,
  13. even though you've got to jump through hoops to really get it into ANSI
  14. mode with the correct ANSI includes.
  15.  
  16.     Here is (a simplified version of) the struct that the compiler
  17. calls an error:
  18.  
  19. struct FM
  20. {
  21.     short    data_len;
  22.     char    data[];        /*  This line is the kicker  */
  23. };
  24.  
  25.     As I recall, ANSI says this is legal, with sizeof( struct FM) is 2 
  26. bytes, and offsetof( struct FM, data) is 2.
  27.  
  28.     I note that the FAQ does not address this issue directly.  It
  29. states (in question 9.6) that the ANSI C standard allows:
  30.  
  31. struct name
  32. {
  33.     int namelen;
  34.     char name[1];
  35. };
  36.  
  37.     only implicitly.  
  38.  
  39.     So, I have two questions: Is the original structure legal ANSI
  40. code?  And if so, what does it take to make HP's cc be ANSI compliant
  41. (-Aa ain't enough) (or have I really found a bug?).  BTW, all my other
  42. compilers have no complaints - the HP compiler does just issue a
  43. warning, it craps out.
  44.  
  45.     Thanks in advance.  (P.S. email preferred unless you think it's of
  46. general interest)
  47.  
  48.  
  49.  _
  50. Kevin D. Quitt      96.37% of all statistics are made up.     srhqla!quest!kdq
  51.