Reputation: 8126
I heard somewhere about 16 bit long char type on some of 64 bit systems. What is the size of char type on Intel 64 (EM64T) system?
Upvotes: 3
Views: 6849
Reputation: 46998
There are two 64-bit ABIs in common use on EM64T / AMD64 systems:
char
as 8 bits (see section 3.1.2).char
as 8 bits (see Types and Storage -> Scalar Types).But the C standard does allow a "byte" to be larger than 8 bits, and a char
is a "byte" (in terms of the C standard) by definition; and such platforms do exist, e.g. some DSPs.
Upvotes: 5
Reputation: 108938
The type char
has CHAR_BIT
bits on every implementation. Don't forget to #include <limits.h>
:)
In C
, a char
is always one byte by definition since the size of a byte is implementation dependent.
#include <limits.h>
#include <stdio.h>
int main(void) {
printf("A char is %d bits wide (*).\n", CHAR_BIT);
puts("(*) in this implementation");
puts(" with the options used for compilation");
puts(" ...");
return 0;
}
Upvotes: 3
Reputation: 5413
That doesn't depend on the ISA, but on the ABI. As far as I know there is no system that defines 1 byte for char
for x64 programs. At least Windows, Linux and FreeBSD don't.
The official x86-64 documentation also specifies 1 byte.
Upvotes: 1