in reply to Re^4: install of Compress::Raw::Zlib on windows7 strawbery perl
in thread install of Compress::Raw::Zlib on windows7 strawbery perl

We are both unclear about why the ptrdiff typedef is needed.

This article may clarify it for you.

The basic problem is down to MS choosing the LLP64 memory model for Win64, while *nix chose the LP64 memory model.

Most pre-64-bit code assumes that an unsigned int is capable of holding a pointer; and a signed int is capable of holding the difference between 2 pointers. That obviously falls down when you move to 64-bit under either model.

Under the LP64 model, ie *nix64, (unsigned) longs can be used for pointer math, but that doesn't work for LLP64.

So C99 defined the intptr_t and ptrdiff_t types as portable types for doing pointer math. (Also size_t time_t etc.)

On any 64-bit capable MSVC, (and presumably on any post-C99 version of gcc), they will be correctly defined whether building for 32 or 64-bit.

But not on the still apparently popular MSC6. Here ptrdiff_t would need to be defined as int (or long?).

None of this is authoritative, just my understanding of it, and you probably know most if not all of it already, but by writing it down clarified the bits and bobs of information floating around in my head, and gives the opportunity that someone might correct any misunderstandings I have.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

  • Comment on Re^5: install of Compress::Raw::Zlib on windows7 strawbery perl