Powiel możliwe:
size of int, long, etc
Does the size of an int depend on the compiler and/or processor?
What decides the sizeof an integer?Jaki powinien być sizeof (int) na 64-bitowym komputerze?
Używam maszynę 64-bit
.
$ uname -m
x86_64
$ file /usr/bin/file
/usr/bin/file: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.32, stripped
$
Kiedy wpadłem następujący program, mam sizeof(int)
jak 4-bytes
.
#include <stdio.h>
int main(void)
{
printf("sizeof(int) = %d bytes\n", (int) sizeof(int));
return 0;
}
Jeśli biegnę trochę maszynę 16-
, 32-
i 64-
, to nie oznacza to, że wielkość statku integer
jest 16-
, 32-
i 64-
nieco odpowiednio?
W mojej maszynie znalazłem numer WORD_BIT
pod numerem 32
. Czy nie powinien to być 64
na komputerze 64-bit
?
$ getconf WORD_BIT
32
$
I nie powinien być 64-bits
sizeof(int)
(8 bytes
) w powyższym przypadku?
Nie jestem osobą C, ale uważam, że rozmiar czegoś oprócz 'char' jest specyficzny dla kompilatora, a także niekoniecznie rozmiar słowa na procesorze. – Ryan
http://stackoverflow.com/questions/589575/size-of-int-long-etc – Perception
@minitech: char jest także kompilatorem specyficznym – Dani