Rolf B: C mal wieder, Länge einer Binary

Beitrag lesen

Hallo TS,

Rheinwerk erweckt den Eindruck, dass es definierte Längen für die diversen Integer-Typen gäbe. Aber das ist nicht der Fall.

Ich habe gerade die Quelle nicht zur Hand, aber die engl. Wikipedia schreibt:

The relation requirements are that the long long is not smaller than long, which is not smaller than int, which is not smaller than short. As char's size is always the minimum supported data type, no other data types (except bit-fields) can be smaller.

The minimum size for char is 8 bits, the minimum size for short and int is 16 bits, for long it is 32 bits and long long must contain at least 64 bits.

The type int should be the integer type that the target processor is most efficiently working with.

Also: sizeof(char) <= sizeof(short) <= sizeof(int) <= sizeof(long) <= sizeof(long long)

Niemand verbietet es einem Compiler, sizeof(char)=8 zu verwenden. Aber dann könnte dieser C-Compiler auch nur 8-Byte Brocken als kleinste Einheit verarbeiten.

Rolf

--
sumpsi - posui - clusi