Article View: comp.std.c
Article #5312The offsetof macro
From: Walter Murray
Date: Fri, 26 Aug 1988 21:36
Date: Fri, 26 Aug 1988 21:36
19 lines
1111 bytes
1111 bytes
I think this may have been discussed a few months ago in comp.lang.c. If so, would someone please mail or post the consensus that was reached? The offsetof macro is supposed to expand to an integral constant expression. There are strict rules about the operands and casts that can be used in an integral constant expression, so, for example, an expression containing "(type *)0" wouldn't be legal. Using such an illegal expression in a place where an integral constant expression is required, such as a case label expression, would violate a constraint and would seemingly require a diagnostic to be produced. So what is a valid way to define offsetof? Thanks Walter Murray All opinions expressed are my own
Technical Details
Message-ID:
<16490006@hpcllca.HP.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!ucsd!ucsdhub!hp-sdd!hplabs!hpda!hpcuhb!hpcllla!hpcllca!walterShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!ucsd!ucsdhub!hp-sdd!hplabs!hpda!hpcuhb!hpcllla!hpcllca!walter From: walter@hpcllca.HP.COM (Walter Murray) Newsgroups: comp.std.c Subject: The offsetof macro Message-ID: <16490006@hpcllca.HP.COM> Date: 26 Aug 88 21:36:49 GMT Organization: HP NSG/ISD California Language Lab Lines: 19