[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: intptr_t vs. uintptr_t

From: Paul Eggert
Subject: Re: intptr_t vs. uintptr_t
Date: Fri, 13 Dec 2019 19:19:46 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.1

On 12/13/19 6:35 PM, Bruno Haible wrote:
>   "Prefer intptr_t for internal representations of pointers"
> I disagree with this advice. uintptr_t ought to be used for representing the
> address of a pointer.

It depends on the application. For example, with two char * pointers P and Q
into an array, it can be helpful that P - Q yields the same integer as
((intptr_t) P - (intptr_t) Q), assuming the usual representation. That's not
true for uintptr_t.

In practice, Emacs uses uintptr_t quite a bit for things like hashes and tags;
but it uses intptr_t a bit more, so the advice seems reasonable for Emacs.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]