Reputation: 6775
I would like to know, if the types that are larger than the native machine word, and that have compiler abstraction support, like int64_t
on a 32 bits system, have any specification on the byte order in memory ?
For example, on little endian machines, should we suppose that the memory layout is a full 64 bits swaped order ? Or it is free to be a middle-endian like the PDP-11 ?
c.f. http://en.wikipedia.org/wiki/Endianness#Middle-endian
Because the __int64 (MS) or long long (gcc) were not standard before int64_t in C99, isn't it far fetched to suppose anything on the byte order of such types ?
Thanks
Upvotes: 5
Views: 1364
Reputation: 4332
I don't think C standard has any specification on the byte order. It's implementation dependent. In practice, I'd supposed that the endianess of int64_t follows the endianess of the architecture. So even in a 32bit program, the storage of int64_t in memory is just as if it were 64bit program. But it may requires two instructions to load/store the data as the register is 32bit.
Upvotes: 0
Reputation: 79021
Why would the standard want to specify on the byte order in memory of anything? In all cases this is up to the compier/architecture to freely decide. If you're interested in a specific architecture, just pop up your debugger and watch how a simple program behaves.
Upvotes: 1
Reputation: 3040
C is a portable language and as such doesn't assume much about the actual representation of integer types. The standard even allows for padding bits sprinkled in between value bits ! For more information, see 6.2.6.2 Integer types.
Upvotes: 0