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?


In reply to Re^5: install of Compress::Raw::Zlib on windows7 strawbery perl by BrowserUk
in thread install of Compress::Raw::Zlib on windows7 strawbery perl by gman

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.