emacs-devel
[Top][All Lists]
Advanced

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

Re: bookkeeping to prepare for a 64-bit EMACS_INT on 32-bit hosts


From: Paul Eggert
Subject: Re: bookkeeping to prepare for a 64-bit EMACS_INT on 32-bit hosts
Date: Mon, 02 May 2011 09:09:17 -0700
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.15) Gecko/20110307 Fedora/3.1.9-0.39.b3pre.fc14 Thunderbird/3.1.9

On 05/02/11 07:46, Stefan Monnier wrote:
>>>>> >>> > -      /* The EMACS_INT cast avoids a warning. */
>>>>> >>> > +      EMACS_INTPTR ii = i;
>>>>> >>> > +      gpointer gi = (gpointer) ii;
>>> >> Is there a particular reason why you use an intermediate var rather
>>> >> than use the more concise "(gpointer) (EMACS_INTPTR) i"?
>> > To avoid a cast.
> I'm not sure what is the formal definition of "cast" in C, but at least
> from my point of view, your code performs just the same kind of coercion
> as a cast.

The runtime behavior is the same, but avoiding the cast can catch more errors.
Suppose "i" is of type "struct tm *", say, and the programmer made a mistake.
Then GCC will issue a helpful diagnostic for the form with just one cast,
but it won't diagnose the more-concise form with two casts.

>> > If you prefer conciseness to avoiding these casts, I can easily change
>> > these to the more-concise form.
> I do prefer the more concise form, and paradoxically part of the reason
> is because it is uses a explicit coercion rather than an implicit one.

OK, will do (unless the above argument convinced you :-).



reply via email to

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