ezpresso
ezpresso

Reputation: 8126

The size of char type on Intel 64 (EM64T) system

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

Answers (3)

Matthew Slattery
Matthew Slattery

Reputation: 46998

There are two 64-bit ABIs in common use on EM64T / AMD64 systems:

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

pmg
pmg

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

Axel Gneiting
Axel Gneiting

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

Related Questions