🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #2524

offsetof

#2524
From: John F Carr
Date: Wed, 06 Mar 1991 23:28
18 lines
922 bytes
Is the following legal C?

	struct foo { struct bar { int a;} b;};
	offsetof(struct foo, a.b);

Section 4.1.5 of the standard doesn't explicitly disallow this, but I wasn't
able to find definitions elsewhere that would tell me if "a.b" is a
structure member or not.

The only compiler I've found that doesn't use some variant of

	#define offsetof(t,m) (size_t)&((struct t *)0)->m

for offsetof does not allow offsetof(struct foo, a.b).  Is it wrong?

--
    John Carr (jfc@athena.mit.edu)
Technical Details
Message-ID: <1991Mar6.232854.22267@athena.mit.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!spool.mu.edu!snorkelwacker.mit.edu!bloom-picayune.mit.edu!news

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!spool.mu.edu!snorkelwacker.mit.edu!bloom-picayune.mit.edu!news
From: jfc@athena.mit.edu (John F Carr)
Newsgroups: comp.std.c
Subject: offsetof
Message-ID: <1991Mar6.232854.22267@athena.mit.edu>
Date: 6 Mar 91 23:28:54 GMT
Sender: news@athena.mit.edu (News system)
Organization: Massachusetts Institute of Technology
Lines: 18