On Thu, 31 Mar 2011, Mark Dootson wrote:
>
> $Config{ptrsize} seems the definitive method. It is 4 or 8 for 32bit /
> 64bit Perl and gets you the right answer if you are running a 32 bit
> Perl on 64 bit Windows.
>
> I think $Config{ivsize} as used in current pp makefiles should always
> work too, but using $Config{ptrsize} seems more directly connected to
> the question.
$Config{ivsize} will actually be 8 even in 32-bit Perl if you compile
with -DUSE_64_BIT_INT:
c:\>\cygwin\bin\perl "-V:(iv|ptr)size"
ivsize='8';
ptrsize='4';
> For choosing 64 bit vs 32 bit pre compiled objects it is the Perl you
> are interested in rather than the operating system.
>
> For info only - I use $ENV{PROCESSOR_IDENTIFIER} if I want to know the
> operating system bitness. This will tell me correct answer even if I'm
> running a 32 bit Perl on a 64 bit system. I keep meaning to seek out a
> better way which there must be.
Win32::GetChipName() from Win32-0.41 and later will return the native
chip name; earlier versions will return the virtual one.
I used to use this code before to get the native OS architecture:
my $arch = $ENV{PROCESSOR_ARCHITEW6432} || $ENV{PROCESSOR_ARCHITECTURE};
Cheers,
-Jan