From: Nobuyoshi Nakada Date: 2007-07-29T08:38:11+09:00 Subject: Re: checking if machine is 64-bit Hi, At Sun, 29 Jul 2007 02:42:46 +0900, Suraj Kurapati wrote in [ruby-talk:262297]: > I am checking if the machine is 64-bit by doing this: > > require 'rbconfig' > is_machine_64_bit = ( Config::CONFIG["arch"] =~ /64/ ) > > Is there a better way? Depends on the purpose. If you are trying to compile an extension library: is_machine_64_bit = check_sizeof("int") == 64 is_machine_64_bit = try_static_assert("sizeof int == 64") or, better in C source(s): #if SIZEOF_VOIDP == 8 Otherwise, if you want to know the current running platform is 64bit: is_machine_64_bit = [0].pack("i!").size == 8 Note that all of the above check for the size of int. -- Nobu Nakada