Re: external data representation

Marc Snir (snir@watson.ibm.com)
Thu, 20 Mar 1997 14:07:26 -0400

This are the Power PC/AIX default sizes, both for gcc and for xlc (the IBM
compiler)

sizeof(char) = 1
sizeof(short) = 2
sizeof(int) = 4
sizeof(long) = 4
sizeof(long long) = 8
sizeof(float) = 4
sizeof(double) = 8
sizeof(long double) = 8

This is for a 32 bit architecture. There is a compilation option that will
make long double 16 byte.
On a 64 bit machine, the main change is that long will be 8 byte, rather
than 4 byte.

By the way, there is an XOPEN standard for 64 bit C, LP64, which is 4/8/8:
4 byte integer, 8 byte long, 8 byte pointers.

The problem of canonical representation occurs not only for files, but also
for sharing between processes, in a regular Unix
environment: X window client and X window server on different systems,
shmat between processes on different nodes, etc.
There have been several proposals to ANSI to have a header file for
fixed-width types: _int8, _in16, _int32, _int64, etc. I would
suggest that any proposal for a canonical file representation should be
coupled with a proposal for a header file for such fixed-width
types.