does anybody know a website or a paper where the sizes of C data types were compared on different machines? I’m interested in values of some ‘big’ machines like a System z or the like.
And:
Is there an upper bound of bytes that the biggest native datatype on any machine can have and is it always of the type complex long double?
Edit: I’m not sure about but does the SIMD register data also take advantage of the CPU’s cache? Data types that will be stored in a special unit and do not use the L1/L2/L cache are out of my interesst. Only the types {char, short, int, long, long long, float, double, long double, _Bool, void *} (and with _Complex) will be examined.
You mention “native” datatypes, but note that
complexis not defined by the C spec and thus isn’t a native type. The native types for C arechar,int,float,double, andvoid.The size of a data type is generally determined by the underlying platform as well as the compiler. The C standard defines the minimum range for these types and defines a few relative relationships (
long intmust be at least as long as a regularint, etc). There’s no easy way to determine the absolute size of any type without testing it.When working with a new platform and I don’t know the particular data type sizes, I write up a short app that dumps the result of
sizeoffor all the standard C types. There are also headers likestdint.hthat give you data types that you can trust to be a certain size.There is no upper bound as to the size of a data type. The C standard defines
charto be “large enough to store any member of the execution character set”. This partially binds the size of the native types to the machine architecture, and so a theoretical machine that had execution characters up to 1MB in size would havesizeof(char)equal to 1MB. Practically speaking, you probably won’t find a machine where this is the case.