home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!think.com!spool.mu.edu!agate!ucbvax!KOPC.HHS.DK!ARNE
- From: ARNE@KOPC.HHS.DK (Arne Vajhxj)
- Newsgroups: comp.os.vms
- Subject: Re: 'ASSUME' macro in VAXC?
- Message-ID: <01GTED1C5FDU8WVYV8@kopc.hhs.dk>
- Date: 11 Jan 93 15:18:58 GMT
- Sender: usenet@ucbvax.BERKELEY.EDU
- Organization: The Internet
- Lines: 36
-
- > Does anybody know any way of implementing compile-time checking in VAXC
- > similar to the ASSUME macro defined in LIB.MLB (or is it STARLET?)?
- >
- > What I want to check for specifically is that the size of a certain struct
- > is equal to 512 bytes and if not, print a warning message.
- >
- > Say:
- > check sizeof(struct foo) "Error: foo is the wrong size"
- >
- > I don't really mind how kludgy the solution would have to be, as long as
- > it works.
-
- A simple easy but kludgy solution to YOUR SPECIFIC problem would be:
-
- #include <stdio.h>
-
- main()
- {
- char x[512];
- /*
- char x[513];
- */
- char check[sizeof(x)==512 ? 1 : -1];
- };
-
- which seems to work both VAX C and GNU C !
-
- Hope it helps !
-
- Arne
-
- Arne Vajhxj local DECNET: KO::ARNE
- Computer Department PSI: PSI%23831001304030::ARNE
- Business School of Southern Denmark Internet: ARNE@KO.HHS.DK
-
-
-