On Tue, Sep 13, 2005 at 08:46:24PM +0200, Andreas Jochens wrote:
> On 05-Sep-13 19:52, Kurt Roeckx wrote:
> > Pretty please stop using longs as something that can hold a
> > pointer.  In general you should not cast a pointer to any integer
> > type.  If you really have to, use an intptr_t type.
> 
> Believe me, a 'long' will do. There is no architecture where
> a 'long' can not hold a full pointer. The linux kernel as
> just one example heavily relies on the fact that 
> sizeof(long)>=sizeof(pointer). 

You're assuming either an (I)LP32 or (I)LP64 architecture here.
An LLP64 architecture still has a long as 32 bit while a pointer
is 64 bit.  The best example of an LLP64 architecture out there
is windows x64.

That the kernel can assume that a long is enough to hold a
pointer is because that's how they defined a long to be.

> Using 'intptr_t' will lead to problems because older C environments do 
> not know about it and sometimes 'configure' scripts do ugly things with 
> 'intptr_t'. As an example, 'e2fsprogs' broke with gcc-4.0 because it 
> used 'intptr_t'.

intptr_t exists for about 10 years now, in either inttypes.h
or stdint.h.  And if something breaks you should fix it.  It's
not that hard to make proper configure checks.


Kurt



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to