Beefy Boxes and Bandwidth Generously Provided by pair Networks Cowboy Neal with Hat
The stupid question is the question not asked
 
PerlMonks  

length of pack 'J' and Win64/Win32 C data type model, pointer length, DWORD_PTR

by patcat88 (Chaplain)
on Nov 07, 2010 at 08:36 UTC ( #869876=perlquestion: print w/ replies, xml ) Need Help??
patcat88 has asked for the wisdom of the Perl Monks concerning the following question:

Am I correct in assuming pack's "J" is 32 bits/4 bytes on Win32 perl and 64bits/8bytes on Win64 perl automatically, without any changes? and "J" is equivalent to the DWORD_PTR type? And "J" is the right type for unpacking DWORD_PTR or void * struct members in Perl? "L" is 32bits on Win32 AND on Win64 perl right (in other words "L" is always 32bits on Windows perl)?

I am trying to make something that has Win64 provisions/is Win64 compatible but don't have any Win64 (x86-64) machines to test my guess on. I guessed the above from the config_h.vc and config_h.vc64 files in the perl source but I can't test my assumptions and I'm not sure if I understood those 2 files correctly.

Comment on length of pack 'J' and Win64/Win32 C data type model, pointer length, DWORD_PTR
Re: length of pack 'J' and Win64/Win32 C data type model, pointer length, DWORD_PTR
by BrowserUk (Pope) on Nov 07, 2010 at 08:47 UTC
    Am I correct in assuming ...

    Yes

    c:\test>\perl32\bin\perl.exe \perl32\bin\p1.pl print length pack 'J', 1;; 4 print length pack 'L', 1;; 4 Terminating on signal SIGINT(2) c:\test>\perl64\bin\perl.exe \perl64\bin\p1.pl print length pack 'J', 1;; 8 print length pack 'L', 1;; 4

    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.
Re: length of pack 'J' and Win64/Win32 C data type model, pointer length, DWORD_PTR
by ikegami (Pope) on Nov 07, 2010 at 15:55 UTC

    No. "J" is 64 bits on a Perl built with 64-bit integer support, and I believe you can have that in a 32-bit binary (and therefore Win32).

    Seems to me you'd want to use "I" if you wanted the pointer itself or "p" if you want what's at the pointer.

      Haven't yet come across a Win32 (32-bit) perl built with 64-bit integer support - but yes, with the right hacks applied to the perl source, it should be possible to build such a perl.

      Cheers,
      Rob

        I'd hardly call a configuration option a hack. (I realise the procedure is different on Windows, but elsewhere it simply involves passing -Duse64bitall to Configure.)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://869876]
Approved by Corion
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (10)
As of 2014-04-17 23:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (459 votes), past polls