home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / vms / 20728 < prev    next >
Encoding:
Text File  |  1993-01-11  |  1.3 KB  |  47 lines

  1. Path: sparky!uunet!think.com!spool.mu.edu!agate!ucbvax!KOPC.HHS.DK!ARNE
  2. From: ARNE@KOPC.HHS.DK (Arne Vajhxj)
  3. Newsgroups: comp.os.vms
  4. Subject: Re: 'ASSUME' macro in VAXC?
  5. Message-ID: <01GTED1C5FDU8WVYV8@kopc.hhs.dk>
  6. Date: 11 Jan 93 15:18:58 GMT
  7. Sender: usenet@ucbvax.BERKELEY.EDU
  8. Organization: The Internet
  9. Lines: 36
  10.  
  11. > Does anybody know any way of implementing compile-time checking in VAXC
  12. > similar to the ASSUME macro defined in LIB.MLB (or is it STARLET?)?
  13. > What I want to check for specifically is that the size of a certain struct
  14. > is equal to 512 bytes and if not, print a warning message.
  15. > Say:
  16. > check sizeof(struct foo) "Error: foo is the wrong size"
  17. > I don't really mind how kludgy the solution would have to be, as long as
  18. > it works.
  19.  
  20. A simple easy but kludgy solution to YOUR SPECIFIC problem would be:
  21.  
  22. #include <stdio.h>
  23.  
  24. main()
  25. {
  26.    char x[512];
  27. /*
  28.    char x[513];
  29. */
  30.    char check[sizeof(x)==512 ? 1 : -1];
  31. };
  32.  
  33. which seems to work both VAX C and GNU C  !
  34.  
  35. Hope it helps !
  36.  
  37.                                                           Arne
  38.  
  39. Arne Vajhxj                             local DECNET:  KO::ARNE
  40. Computer Department                     PSI:           PSI%23831001304030::ARNE
  41. Business School of Southern Denmark     Internet:      ARNE@KO.HHS.DK
  42.  
  43.  
  44.