Re: Determining architecture type at run time
site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com On Apr 27, 2009, at 2:02 PM, rohan a wrote: Hi, Thanks for this. I tried the following : #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <sys/sysctl.h> extern int errno; int main(void) { int len; char cpuarch[64]; However, sysctlbyname fails with the error sysctlbyname(): No such file or directory What needs to be done? $ man 3 sysctl On Apr 27, 2009, at 12:11 PM, rohan a wrote: Thanks _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... ENOENT is "no such file or directory". That would mean there's no name mapping for hw.machine_arch, so use sysctl() instead with HW_MACHINE_ARCH as the MIB ID. len = sizeof(cpuarch); if (sysctlbyname("hw.machine_arch", cpuarch, &len, NULL, NULL) == -1) { perror("sysctlbyname()"); return -1; } return 0; } On 4/27/09, Brian Bergstrand <brian@classicalguitar.net> wrote: #include <sys/sysctl.h> Hello, I need to determine at program run time, the architecture type(x86, ppc or x86_64) of the Mac OS X machine. Is it possible to do this? Does Mac OS provide any API for this? This email sent to site_archiver@lists.apple.com
participants (1)
-
Brian Bergstrand