home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!munnari.oz.au!yarrina.connect.com.au!warrane.connect.com.au!g2syd!roberts
- From: roberts@g2syd.genasys.com.au (Robert Swan)
- Subject: offsetof in case labels
- Message-ID: <1993Jan21.232337.6527@g2syd.genasys.com.au>
- Organization: Genasys II, Sydney, Australia
- Date: Thu, 21 Jan 1993 23:23:37 GMT
- Lines: 31
-
- I posted a related question a week or two ago. ~no response, so I'll
- try a different tack.
-
- 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.
-
- I consider this to be irrelevant, since (as I understand it) the
- offsetof macro returns, by definition, a constant expression - exactly
- what a case label needs. The fact that it is usually (always)
- implemented as a pointer expression is an implementation detail.
-
- However, I'm pretty much at sea with the ANSI standard - we don't have a
- copy, and the excerpts I have seen of it suggest that it is written in
- sufficiently obscure legalese to cloud the superficial interpretation I
- might put on it. Could someone who has invested the considerable
- effort to understand the standard please clear this up for me.
-
- Should offsetof be usable in case labels?
-
- Have fun,
-
- Robert.
- --
- I used to be indecisive, | Robert Swan, roberts@g2syd.genasys.com.au
- but now I'm not so sure. | Genasys II Pty. Ltd., North Sydney.
-