Next: RM A 1 52 Names of Predefined Numeric Types, Previous: RM 13 11 2 17 Unchecked Deallocation, Up: Implementation Advice [Contents][Index]
"If a stream element is the same size as a storage element, then the normal in-memory representation should be used by
Read
andWrite
for scalar objects. Otherwise,Read
andWrite
should use the smallest number of stream elements needed to represent all values in the base range of the scalar type."
Followed. By default, GNAT uses the interpretation suggested by AI-195,
which specifies using the size of the first subtype.
However, such an implementation is based on direct binary
representations and is therefore target- and endianness-dependent.
To address this issue, GNAT also supplies an alternate implementation
of the stream attributes Read
and Write
,
which uses the target-independent XDR standard representation
for scalar types.
The XDR implementation is provided as an alternative body of the
System.Stream_Attributes
package, in the file
s-stratt-xdr.adb
in the GNAT library.
There is no s-stratt-xdr.ads
file.
In order to install the XDR implementation, do the following:
System.Stream_Attributes
package with the XDR implementation.
For example on a Unix platform issue the commands:
$ mv s-stratt.adb s-stratt-default.adb $ mv s-stratt-xdr.adb s-stratt.adb