🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #3734

Re: Why "long long" doesn't work.

#3734
From: Colin Plumb
Date: Tue, 15 Aug 1995 22:28
16 lines
1049 bytes
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:

#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.
-- 
	-Colin
Technical Details
Message-ID: <40r72s$m9f@nyx10.cs.du.edu>
Path: arc1-ca.pugleaf.net!nyx10.cs.du.edu!not-for-mail
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>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!nyx10.cs.du.edu!not-for-mail
From: colin@nyx10.cs.du.edu (Colin Plumb)
Newsgroups: comp.std.c
Subject: Re: Why "long long" doesn't work.
Date: 15 Aug 1995 16:28:44 -0600
Organization: University of Denver, Dept. of Math & Comp. Sci.
Message-ID: <40r72s$m9f@nyx10.cs.du.edu>
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>
NNTP-Posting-Host: nyx10.cs.du.edu