Article View: net.lang.c++
Article #14Re: porting C++
From: Joseph Pallas
Date: Sun, 16 Feb 1986 23:15
Date: Sun, 16 Feb 1986 23:15
39 lines
1644 bytes
1644 bytes
With respect to size/align files, I wrote this little bit of code in C
that generates some (but not all) of the required information. Can anyone
tell me why the compiler wants some of the more obscure stuff, and how I
can figure it out at runtime in a C program?
/* alignments tester */
struct c { char c1; char c2;};
struct s { char c; short s;};
struct i { char c; int i;};
struct l { char c; long l;};
struct f { char c; float f;};
struct d { char c; double d;};
struct ch { char c;};
struct st { char c; struct ch sc;};
struct wp { char c; int *wp;};
struct bp { char c; char *bp;};
#define CHECK(name,type,struc) printf("%s %d %d\n",\
name, sizeof(type), sizeof(struc) - sizeof(type))
main()
{
CHECK("char", char, struct c);
CHECK("short", short, struct s);
CHECK("int", int, struct i);
CHECK("long", long, struct l);
CHECK("float", float, struct f);
CHECK("double", double, struct d);
CHECK("struct", struct ch, struct st);
CHECK("wptr", int *, struct wp);
CHECK("bptr", char *, struct bp);
}
---
Joe Pallas
...decwrl!glacier!navajo!pallas
pallas@navajo.stanford.edu
Technical Details
Message-ID:
<370@Navajo.ARPA>Path:
arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!glacier!Navajo!pallasReferences:
<4982@alice.uUCp>Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: arc1-ca.pugleaf.net!utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!decwrl!glacier!Navajo!pallas From: pallas@Navajo.ARPA (Joseph Pallas) Newsgroups: net.lang.c++ Subject: Re: porting C++ Message-ID: <370@Navajo.ARPA> Date: Sun, 16-Feb-86 18:15:53 EST Article-I.D.: Navajo.370 Posted: Sun Feb 16 18:15:53 1986 Date-Received: Tue, 18-Feb-86 03:29:37 EST References: <4982@alice.uUCp> Organization: Stanford University Lines: 39