Non posso usare "long long"; cosa dovrei usare?Su Mac OS X in C++ su una CPU a 64 bit, esiste un tipo a 64 bit?
risposta
Presumendo Snow Leopard (Mac OS X 10.6.2 - Intel), quindi 'long' è 64 bit con il compilatore predefinito.
Specificare 'g ++ -m64' e sarà probabilmente 64-bit anche nelle versioni precedenti.
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))
Testato con:
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.
compilazione con GCC 4.7.1 su Mac OS X 10.7.5 con l'opzione -std=c99
, l'output del programma è più ampio. Grazie a apalopohapa per aver segnalato la svista che long long
ecc. Mancava all'originale.
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; })
Inoltre, se si include
int64_t * at al * sono in realtà in
Affidarsi al tavolo che hai appena postato è un cattivo consiglio. Se vuoi 64 bit, usa 'int64_t'. È standard per una ragione. – asveikau
Includere <stdint.h>
o <inttypes.h>
(il più tardi è trovato in alcuni altri compilatori, ma entrambi sono forniti dal compilatore di Apple), e utilizzare uint64_t
e int64_t
. Sono 64 bit su target a 32 e 64 bit.
- 1. Come creare Python a 64 bit su OS X 10.6 - SOLO 64 bit, niente assurdità universale
- 2. Come verificare se una libreria è basata su 32 bit/64 bit su Mac OS X?
- 3. puntatore C++ su macchina a 64 bit
- 4. Compilare binario a 32 bit su sistema a 64 bit
- 5. Come compilare un programma C++ come 64-bit su un computer a 64 bit?
- 6. SQL Server 2012 a 32 bit o 64 bit su computer a 64 bit?
- 7. Applicazione DirectX su finestre a 64 bit
- 8. Boost.Test su Windows a 64 bit
- 9. Ente a 64 bit? C#
- 10. Compilare i binari OS X a 32 bit in un ambiente a 64 bit
- 11. iPhone OS 64 bit o 32 bit?
- 12. strtok su macchine a 64 bit
- 13. Interoperabilità a 32 e 64 bit su Windows a 64 bit
- 14. Python è ctypes.c_long a 64 bit su sistemi a 64 bit?
- 15. Esiste un modo per eseguire programmi a 64 bit su un computer a 32 bit?
- 16. È possibile compilare svdlibc su un mac (64 bit)?
- 17. allineamento uint32_t su 64-bit?
- 18. Sto sviluppando un'applicazione a 64 bit. È possibile eseguire l'applicazione a 64 bit su un sistema operativo a 32 bit?
- 19. App Java a 64 bit: è richiesto un sistema operativo a 64 bit, JRE a 64 bit e applicazione a 64 bit?
- 20. Esecuzione di codice assembly a 32 bit su un processore Linux a 64 bit e 64 bit: Spiegazione dell'anomalia
- 21. Applicazione a 32 o 64 bit su sistema operativo a 64 bit?
- 22. SDK Android a 32 o 64 bit su sistema operativo Windows a 64 bit?
- 23. Fare riferimento a "Programmi" su un computer a 64 bit
- 24. Compilando 32 bit Assembler su ubuntu a 64 bit
- 25. C# PInvoking user32.dll su un sistema a 64 bit
- 26. Esegui libreria a 32 bit su iPhone 5s 64 bit
- 27. Domanda Quicktime a 64 bit
- 28. sizeof (long) in C++ a 64 bit
- 29. Perché __sync_add_and_fetch funziona per una variabile a 64 bit su un sistema a 32 bit?
- 30. prestazioni a 32 bit vs 64 bit aritmetica
Perché non puoi usare "long long"? Il tuo compilatore non lo supporta? –
Che compilatore stai usando? – Cameron
Darwin/MacOSX supporta i typedefs di numeri interi fissi, come int64_t? Se è così, userei quelli. Vedi http://www.opengroup.org/onlinepubs/000095399/basedefs/stdint.h.html per i dettagli. – Void