Page 1 of 1

How can I check programatically if System is 32/64 bit (Mac)

Posted: Sat Apr 27, 2013 5:15 pm
by spacebuddy
Any help appreciated :D

Re: How can I check programatically if System is 32/64 bit (

Posted: Sat Apr 27, 2013 5:45 pm
by wilbert
Maybe a silly question but why would you want to ?

OS X 32 bit can run 64 bit applications and OS X 64 bit can run 32 bit applications.
The only important thing is if the CPU is capable of 64 bit. From the intel based Mac's, only the first generation that wasn't sold for very long didn't have 64 bit support.
Most users will probably be able to run a 64 bit application but if you want to be sure, you can always compile a 32 bit application.

Re: How can I check programatically if System is 32/64 bit (

Posted: Sat Apr 27, 2013 6:38 pm
by spacebuddy
wilbert wrote:Maybe a silly question but why would you want to ?

OS X 32 bit can run 64 bit applications and OS X 64 bit can run 32 bit applications.
The only important thing is if the CPU is capable of 64 bit. From the intel based Mac's, only the first generation that wasn't sold for very long didn't have 64 bit support.
Most users will probably be able to run a 64 bit application but if you want to be sure, you can always compile a 32 bit application.

I need this to put into my AboutBox that shows the user system information :D

I have this in my Windows version so I want to be consistent with the Mac version
and add this.

Just can't find any information on how to do it in Mac. :(

Re: How can I check programatically if System is 32/64 bit (

Posted: Sun Apr 28, 2013 6:25 am
by J. Baker

Code: Select all

GetBit = RunProgram("uname", "-m", "", #PB_Program_Open | #PB_Program_Read)
Bit$ = ""
While ProgramRunning(GetBit)
  If AvailableProgramOutput(GetBit)
    Bit$ = ReadProgramString(GetBit)
  EndIf
Wend
CloseProgram(GetBit)
Debug Bit$

Re: How can I check programatically if System is 32/64 bit (

Posted: Sun Apr 28, 2013 4:57 pm
by spacebuddy
J. Baker wrote:

Code: Select all

GetBit = RunProgram("uname", "-m", "", #PB_Program_Open | #PB_Program_Read)
Bit$ = ""
While ProgramRunning(GetBit)
  If AvailableProgramOutput(GetBit)
    Bit$ = ReadProgramString(GetBit)
  EndIf
Wend
CloseProgram(GetBit)
Debug Bit$
Thanks for the info. But I am looking for an api, rather not use terminal. :D

I was using sysctl hw.cpu64bit_capable from the terminal, but removed it from the program.

Re: How can I check programatically if System is 32/64 bit (

Posted: Sun Apr 28, 2013 5:19 pm
by wilbert
spacebuddy wrote:I was using sysctl hw.cpu64bit_capable from the terminal, but removed it from the program.
sysctl can be used as an api, you don't need to use it from the terminal.
But hw.cpu64bit_capable only tells you something about the cpu, not about what mode the OS is running.