home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: offsetof in case labels
- Message-ID: <1993Jan22.190518.13167@taumet.com>
- Organization: TauMetric Corporation
- References: <1993Jan21.232337.6527@g2syd.genasys.com.au>
- Date: Fri, 22 Jan 1993 19:05:18 GMT
- Lines: 22
-
- roberts@g2syd.genasys.com.au (Robert Swan) writes:
-
- >We have a problem on various machines using the offsetof macro from
- >stddef.h in case labels. These machines all reject the expression as
- >being non-constant.
-
- >A representative of one of the machine vendors (IBM), has glibly stated
- >that the compiler is doing the right thing by rejecting it. He has
- >quoted the ANSI standard arguing (in fairly obscure terms) that the
- >compiler is free to treat various pointer expressions as non constant.
-
- ANSI C Standard, section 3.6.4.1, "The switch Statement":
- "The expression of each case label shall be an integral constant expression."
-
- ANSI C Standard, section 4.1.5, "Common Definitions <stddef.h>":
- "... offsetof ... expands to an integral constant expression that has
- type size_t ..."
-
- It seems pretty clear that what you want to do is supposed to be legal.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
-