Is Linux 32 or 64-bit?

Is there a way to determine if the Linux OS you’re running on is Linux 32 or 64-bit?

I don’t mean Xojo with #targetLinux or the CPU, but Linux itself. With MacOS I can assume it is 64-bit (the below commands work on Mac) and MBS have a routine for Windows to tell if the OS is 32 or 64 bit, bit I can’t find any solution within Xojo or without regarding Linux.

On line Shell suggestions are:

uname -m 'returns code containing x86_64 getconf LONG_BIT 'returns 64

But are these accurate or is there a better way?

Don’t the #pragma isTarget32bit/64bit compiler commands work on Linux? You could set a variable using them.

(EDIT: In better words:
#If Target32bit … #Endif)

[quote=163384:@Ulrich Bogun]Don’t the #pragma isTarget32bit/64bit compiler commands work on Linux? You could set a variable using them.

(EDIT: In better words:
#If Target32bit … #Endif)[/quote]
No. Because we don’t compile for 64-bit on Linux yet, Target64Bit will always return False and Target32Bit will always return True, even if you’re on a 64-bit system.

How about asking the CPU like this:

[code] dim c as new CPUIDMBS

if c.Flags(CPUIDMBS.kFeatureLM) then
MsgBox “64-bit CPU”
else
MsgBox “32-bit CPU”
end if[/code]

Ah sure, yes, of course! Thanks, Greg.

Christian, that would tell me if it has a 32/64-bit CPU, but I might be running 32-bit Linux on a 64-bit CPU. Or is your function actually returning the Linux capability (and not the chip)? If I am running running 32-bit Linux on a 64-bit CPU I want it to return ‘32’.

[quote=163382:@David Cox]On line Shell suggestions are:

uname -m 'returns code containing x86_64 getconf LONG_BIT 'returns 64

But are these accurate or is there a better way?[/quote]

The first is accurate and the best way because it will differentiate between running 32bit Linux on a 64bit processor (reporting i386, i586, or i686) and actually running 64bit Linux (x86_64).

The second won’t be since Xojo doesn’t compile for 64bit yet and that will always be false.

Shell to :

uname -a