XFX3d opened this issue on Nov 13, 2005 ยท 83 posts
XFX3d posted Tue, 15 November 2005 at 1:05 PM
"Beware how you output the value of WORD and DWORD, in Mac it will work normally, but in PC you must create special routines" Well, rather than using the local byte significance, my pack() template up there specifically uses N and n for DWORDs and WORDs, respectively (or, rather, in a more perlish sense, long and short integers). The N/n is a specific packing format. It's automatically big-endian, and always 32 or 16 bits exactly. This is in contract with i and I which are signed and unsigned integers respectively which are compiler-depentent in length and architecture dependent in byte order. s and S which are short integers following the same logic, l and L are similar, but always exactly 32 bits, still architecture dependent on byte order, and v and V are like the n and N sizes, but always little-endian. q and Q are quad (64 bit) values, but if your system doesn't support 64 bit integers or Perl wasn't compiled to support them, it fatals when it runs. As a result, only n, N, v and V of all of these are recommended for portability. For mnenonic, N stands for 'Network Order' (big endian, like a Motorola or Sun processor) and v stands for 'Vax Order' (little-endian, like a Vax or IA-32 based machine). So yeah, from C you would, but Perl handles the difference quite cleanly and even expects to deal with it. Big reason is that Perl has come installed standard on UNIX and Linux machines for a decade and is meant as a fast scripting language. Not building in portable-output options would make a lot of messes, especialy since the most popular *nixes are Linux (usually on x86 so little-endian), Solaris (big-endian), and the currently immensely popular FreeBSD (which may be either, as it works fine on a x86 box, but it's most popular distribution nowadays is named after assorted jungle cats, currently Tiger, and very much big-endian).
I'm the asshole. You wanna be a shit? You gotta go through ME.