如何在OS X中使用標準C庫或Cocoa獲取CPU體系結構字符串?在OS X中獲取CPU arch字符串(C,Cocoa)
2
A
回答
2
2
這裏有一個作弊的方式排序:
#if defined(__i386__)
return "i386";
#elif defined(__x86_64__)
return "x86-64";
#elif defined(__arm__)
return "arm";
// etc...
#else
# error "Unknown architecture!"
#endif
這不是絕對必要的檢查在運行時,因爲有一個爲每個架構一個單獨的可執行映像。
0
從man 2 uname
:
#include <sys/utsname.h>
int uname(struct utsname *buf);
uname() returns system information in the structure pointed to by buf.
The utsname struct is defined in
<sys/utsname.h>:
struct utsname {
char sysname[]; /* Operating system name (e.g., "Linux") */
char nodename[]; /* Name within "some implementation-defined
network" */
char release[]; /* OS release (e.g., "2.6.28") */
char version[]; /* OS version */
char machine[]; /* Hardware identifier */
};
The length of the arrays in a struct utsname is unspecified;
the fields are terminated by a null byte ('\0').
提示: uname -m輸出返回(struct utsname).machine
。
相關問題
- 1. OS X獲取字符串
- 2. cocoa objective-c for os x:從路徑獲取卷裝入點
- 3. cocoa arc4random OS X 10.6
- 4. 從C獲取Mac OS X上的CPU數量?
- 5. OS X webview獲取實際的文件名字符串
- 6. 在OS X Cocoa中的java.awt.Robot等價物?
- 7. 在c/cocoa中讀取和輸出UTF-8字符串
- 8. CPU使用率OS X接口
- 9. 如何在OS X上獲取CPU溫度和風扇速度?
- 10. 在C#中獲取子字符串?
- 11. 在字符串中獲取字符串
- 12. Mono for OS X和Cocoa
- 13. NSWindow vs ViewController - OS X - Cocoa
- 14. VTK Java OS-X,Cocoa異常
- 15. 如何獲取distutils用於構建的arch字符串?
- 16. OS X arch命令不正確
- 17. 在字符串中獲取字符串c
- 18. 獲取的字符串C#
- 19. 如何在OS X上使用sed提取子字符串?
- 20. OS X Cocoa - 將虛擬掃描代碼轉換爲Char字符
- 21. 字符串模塊出錯,python os x
- 22. 凍結Cocoa中的OS X屏幕
- 23. 如何在Mac OS X中使用Cocoa和CGDisplayCreateImageForRect獲取區域截圖?
- 24. 獲取當前pthread cpu使用情況Mac OS X
- 25. 從字符串中獲取X字符與PHP繞回
- 26. 如何從C#中的字符串中獲取字符串的子字符串?
- 27. Objective-C串行 - Mac OS X
- 28. 在字符串中獲取字符數
- 29. C++字符串在Windows和Mac OS
- 30. C++ Lua中,獲取全局字符串
我不知道C很好,但我會運行'uname -m'並獲取輸出。 – Blender 2011-12-21 19:04:52