I know that I can use the terminal and the system-profiler command to determine the current bitness of the kernel but I am trying to determine if there is a way to get that
You could use sysctlbyname. Dig around mach/machine.h
to get possible values.
#include <mach/machine.h>
#include <sys/sysctl.h>
void example()
{
unsigned int cpuType;
size_t size = sizeof(cpuType);
sysctlbyname("hw.cputype", &cpuType, &size, NULL, 0);
bool is64 = cpuType & CPU_ARCH_ABI64;
const char *cpu;
switch (cpuType) {
case CPU_TYPE_X86:
cpu = "x86";
break;
case CPU_TYPE_X86_64:
cpu = "x86_64";
break;
case CPU_TYPE_POWERPC:
cpu = "ppc";
break;
case CPU_TYPE_POWERPC64:
cpu = "ppc_64";
break;
case CPU_TYPE_SPARC:
cpu = "sparc";
break;
default:
cpu = "unknown";
break;
}
}
See man 3 uname: It fills a utsname
structure which includes a member machine
, which is "x86_64"
or "i386"
on Intel platforms:
struct utsname un;
int res = uname(&un);
if (res >= 0) {
NSLog(@"%s", un.machine);
}
You should be able to read the system profiler information in from command line like this:
sys_profile = popen("system_profiler -xml", "r");
See the ProfileSystem example in Apple's documentation for how to parse it.
Software/System Software Overview/64-bit Kernel and Extensions is probably the key you want.