Article View: comp.std.c
Article #3733Re: Why "long long" doesn't work.
From: Tanmoy Bhattacharya
Date: Tue, 15 Aug 1995 22:43
Date: Tue, 15 Aug 1995 22:43
31 lines
1880 bytes
1880 bytes
In article <40r72s$m9f@nyx10.cs.du.edu>, colin@nyx10.cs.du.edu (Colin Plumb)
writes:
|> In article <DANIELV.95Aug10093924@crt0.crt>,
|> Daniel Villeneuve <danielv@crt0.crt> wrote:
|> >
|> > The required alignment of that type is also of interest, when writing a
|> > specialized malloc() portably. gcc's __alignof__ extension may be used
|> > as a model/example.
|>
|> While it doesn't generalize to variables, here's a simple and, as far
|> as I know, portable alignof() macro:
This probably does work on most implementations:but as far as I am aware, the
standard puts no restriction on padding: and hence, there is _absolutely_ no
reason why this should work.
|>
|> #define alignof(type) (sizeof(struct{type _x; char _y;}) - sizeof(type))
|>
|> _x and _y may get caught somewhere in the user's code, but this has
|> worked for me quite well in practice.
Cheers
Tanmoy
--
tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87544-0285,USA H:#3,802,9 St,NM87545
Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
<http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
Technical Details
Message-ID:
<40r7uf$iit@newshost.lanl.gov>Path:
arc1-ca.pugleaf.net!qcd.lanl.gov!tanmoyReferences:
<3uvcje$c3q@goanna.cs.rmit.edu.au> <3vq4p5$8dv@wsrcom.wsr.ac.at> <409fr9$guo@goanna.cs.rmit.edu.au> <DANIELV.95Aug10093924@crt0.crt> <40r72s$m9f@nyx10.cs.du.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!qcd.lanl.gov!tanmoy From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya) Newsgroups: comp.std.c Subject: Re: Why "long long" doesn't work. Date: 15 Aug 1995 22:43:27 GMT Organization: Los Alamos National Laboratory Distribution: world Message-ID: <40r7uf$iit@newshost.lanl.gov> References: <3uvcje$c3q@goanna.cs.rmit.edu.au> <3vq4p5$8dv@wsrcom.wsr.ac.at> <409fr9$guo@goanna.cs.rmit.edu.au> <DANIELV.95Aug10093924@crt0.crt> <40r72s$m9f@nyx10.cs.du.edu> NNTP-Posting-Host: qcd.lanl.gov