Re: 32 bit / 64 bit integer confusion
| From: | Pierre Joye | Date: | Fri, 10 Jun 2011 14:54:54 +0000 |
| Subject: | Re: 32 bit / 64 bit integer confusion | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-53244@lists.php.net to get a copy of this message | ||
hi,
On Fri, Jun 10, 2011 at 4:47 PM, Derick Rethans <derick@php.net> wrote:
> On Fri, 10 Jun 2011, Hannes Landeholm wrote:
>
>> What are the reasoning behind this? I think the PHP integer size
>> should be changed to always be 64 bit - independent of the platform. I
>> have stumbled on this annoying inconsistency several times the last
>> month.
>
> I agree that that should be the same. But sadly, Windows uses a
> different integer size model than almost everything else modern.
> Where Linux and Mac and other unices use 8 bytes for an "int", Windows
> uses 4 bytes (http://en.wikipedia.org/wiki/LP64#Specific_C-language_data_models).
> Because PHP internally uses "int" for its integer type, on Windows
> that's still only 32 bit.
The sad part is not that windows uses a consistent type size across
architecture but that linux and gcc considers that a type could be
whatever the architecture uses. Hence why stdint.h was introduced and
should be used instead of the long/int.
> But yes, it would be awesome if PHP actually took care of this and uses
> 64 bit ints on 64 bit processors.
A type should be the same on all architecture, even more at the PHP
script level.
Cheers,
--
Pierre
@pierrejoye | http://blog.thepimp.net | http://www.libgd.org