Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: reliably test integer size for portable bit-fiddling?

by Tux (Canon)
on Dec 08, 2014 at 21:34 UTC ( [id://1109644]=note: print w/replies, xml ) Need Help??


in reply to reliably test integer size for portable bit-fiddling?

The j format is still architecture depending, as the others already showed. If your perl has 64bit ints (even if the poiters are just 32bit), does q (or Q) work for you? (for portability, do not forget < or >). That won't work on 32-bit-only perl builds.

$ perl -MDP -we'DHexDump pack "Q", 0x12345678' 0000 78 56 34 12 00 00 00 00 xV4..... $ perl -MDP -we'DHexDump pack "Q>", 0x12345678' 0000 00 00 00 00 12 34 56 78 .....4Vx $ perl -MDP -we'DHexDump pack "Q<", 0x12345678' 0000 78 56 34 12 00 00 00 00 xV4..... $ perl -V:uvsize uvsize='8'; other perl $ perl -V:uvsize uvsize='4'; $ perl -wle'print length pack "Q", 3' Invalid type 'Q' in pack at -e line 1.

Enjoy, Have FUN! H.Merijn

Replies are listed 'Best First'.
Re^2: reliably test integer size for portable bit-fiddling?
by Anonymous Monk on Dec 09, 2014 at 00:54 UTC
    I had written once  use constant CAN_PACK_QUADS => !! eval { my $f = pack 'q'; 1 }; cause it dies when it can't

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1109644]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-23 20:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found