我不能用「long long」;我應該使用什麼?在64位CPU上的C++中的Mac OS X上,是否有64位的類型?
5
A
回答
12
假設Snow Leopard(Mac OS X 10.6.2 - Intel),那麼'長'是64位的默認編譯器。
指定'g ++ -m64',它在早期版本中可能也是64位。
1 = sizeof(char)
1 = sizeof(unsigned char)
2 = sizeof(short)
2 = sizeof(unsigned short)
4 = sizeof(int)
4 = sizeof(unsigned int)
8 = sizeof(long)
8 = sizeof(unsigned long)
4 = sizeof(float)
8 = sizeof(double)
16 = sizeof(long double)
8 = sizeof(size_t)
8 = sizeof(ptrdiff_t)
8 = sizeof(time_t)
8 = sizeof(void *)
8 = sizeof(char *)
8 = sizeof(short *)
8 = sizeof(int *)
8 = sizeof(long *)
8 = sizeof(float *)
8 = sizeof(double *)
8 = sizeof(int (*)(void))
8 = sizeof(double (*)(void))
8 = sizeof(char *(*)(void))
與測試:
i686-apple-darwin10-g++-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5646) (dot 1) Copyright (C) 2007 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
在Mac OS X 10.7.5使用GCC 4.7.1編譯與選項-std=c99
,從程序的輸出更加廣泛。感謝apalopohapa,指出long long
等原本缺失的疏漏。
1 = sizeof(char)
1 = sizeof(unsigned char)
2 = sizeof(short)
2 = sizeof(unsigned short)
4 = sizeof(int)
4 = sizeof(unsigned int)
8 = sizeof(long)
8 = sizeof(unsigned long)
4 = sizeof(float)
8 = sizeof(double)
16 = sizeof(long double)
8 = sizeof(size_t)
8 = sizeof(ptrdiff_t)
8 = sizeof(time_t)
8 = sizeof(long long)
8 = sizeof(unsigned long long)
8 = sizeof(uintmax_t)
1 = sizeof(int8_t)
2 = sizeof(int16_t)
4 = sizeof(int32_t)
8 = sizeof(int64_t)
1 = sizeof(int_least8_t)
2 = sizeof(int_least16_t)
4 = sizeof(int_least32_t)
8 = sizeof(int_least64_t)
1 = sizeof(int_fast8_t)
2 = sizeof(int_fast16_t)
4 = sizeof(int_fast32_t)
8 = sizeof(int_fast64_t)
8 = sizeof(uintptr_t)
8 = sizeof(void *)
8 = sizeof(char *)
8 = sizeof(short *)
8 = sizeof(int *)
8 = sizeof(long *)
8 = sizeof(float *)
8 = sizeof(double *)
8 = sizeof(int (*)(void))
8 = sizeof(double (*)(void))
8 = sizeof(char *(*)(void))
1 = sizeof(struct { char a; })
2 = sizeof(struct { short a; })
4 = sizeof(struct { int a; })
8 = sizeof(struct { long a; })
4 = sizeof(struct { float a; })
8 = sizeof(struct { double a; })
16 = sizeof(struct { char a; double b; })
16 = sizeof(struct { short a; double b; })
16 = sizeof(struct { long a; double b; })
4 = sizeof(struct { char a; char b; short c; })
16 = sizeof(struct { char a; char b; long c; })
4 = sizeof(struct { short a; short b; })
6 = sizeof(struct { char a[3]; char b[3]; })
8 = sizeof(struct { char a[3]; char b[3]; short c; })
16 = sizeof(struct { long double a; })
32 = sizeof(struct { char a; long double b; })
16 = sizeof(struct { char a; long long b; })
16 = sizeof(struct { char a; uintmax_t b; })
3
包括<stdint.h>
或<inttypes.h>
(後來是在一些編譯器中,但兩者都是由蘋果公司提供的編譯器),並使用uint64_t
和int64_t
。它們在32位和64位目標上都是64位的。
相關問題
- 1. 檢測Mac OS X上的Ruby 64位CPU
- 2. 64位CPU上的VMware 4 ESXi是否運行64位客人?
- 3. 32位和64位CPU/OS
- 4. 可以在64位Mac OS X上使用32位eclipse RCP嗎?
- 5. 在Mac OS X 64位上的Java Service Wrapper 3.2.3
- 6. 在OS X上轉移到64位?
- 7. hadoop-2.2.0在Mac OS X上執行失敗64位
- 8. 如何在Mac OS X 64位上獲取默認音量?
- 9. 無法在mac os上安裝64位mysql x 10.6
- 10. 在Mac OS X 64位上編譯S-Transform Python包裝
- 11. 試圖在OS X上編譯32位和64位的GNU庫
- 12. Python:如何知道OS/CPU是64位
- 13. 在64位機器上調用64位Dephi DLL從C#在64位機器上
- 14. 爲什麼我無法在64位CPU上安裝64位Ubuntu?
- 15. 64位整數在64位與86 OS
- 16. macOS上的Python c_ulong類型爲64位
- 17. 在64位處理器上運行32位程序集與mac os x
- 18. Mac上的GetApplicationScript()的等效64位
- 19. 在OS X 10.8(64位)上交叉編譯rsync到10.7(32位)
- 20. OpenCV的建設與Java支持在Mac OS X(64位)
- 21. 64位mac上的android開發
- 22. Mac上的Mono 64位。缺少4.5
- 23. Matplotlib.pyplot在OS X上使用Python.org提供的64位Python
- 24. 構建apr-util 64位Mac OS X構建32位版本
- 25. OpenCV 2.1 Mac OS X攝像頭問題32位和64位
- 26. NASM和gcc:32位鏈接失敗(64位Mac OS X)
- 27. 爲什麼我在32位Mac OS X系統上看到C++中的64位指針?
- 28. 編譯SQLCipher在Mac OS 10.8(64位)
- 29. 在Linux OS 64位上構建Hibernate 3.2.0
- 30. 在win7上的OllyDbg 64位
爲什麼你不能使用'long long'?你的編譯器不支持它嗎? – 2010-03-04 23:40:14
你使用什麼編譯器? – Cameron 2010-03-04 23:43:19
達爾文/ MacOSX是否支持固定大小的整型typedefs,如int64_t?如果是這樣,我會使用這些。有關詳細信息,請參閱http://www.opengroup.org/onlinepubs/000095399/basedefs/stdint.h.html。 – Void 2010-03-04 23:53:47