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

Mac OSX specific forum
spacebuddy
Enthusiast
Enthusiast
Posts: 364
Joined: Thu Jul 02, 2009 5:42 am

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

Post by spacebuddy »

Any help appreciated :D
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3944
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

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

Post 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.
Windows (x64)
Raspberry Pi OS (Arm64)
spacebuddy
Enthusiast
Enthusiast
Posts: 364
Joined: Thu Jul 02, 2009 5:42 am

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

Post 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. :(
User avatar
J. Baker
Addict
Addict
Posts: 2196
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

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

Post 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$
www.posemotion.com

PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef


Even the vine knows it surroundings but the man with eyes does not.
spacebuddy
Enthusiast
Enthusiast
Posts: 364
Joined: Thu Jul 02, 2009 5:42 am

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

Post 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.
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3944
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

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

Post 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.
Windows (x64)
Raspberry Pi OS (Arm64)
Post Reply