Exact data representation[edit | edit source]
It is important to realize that pragma Pack must not be used to specify the exact representation of a data type, but to help the compiler to improve the efficiency of the generated code. The compiler is free to ignore the pragma, therefore if a specific representation of a type is required, representation clauses should be used instead (record representation clauses, and/or attributes 'Size or 'Component_Size).
Bit-wise operations[edit | edit source]
Although in Ada 83 packed boolean arrays were used for bit-wise operations, since Ada 95 modular types are more adequate for these operations. The argument may be weighed against the advantages of named Boolean array indexes such as Traffic_Lights'(Red => True,
others => False), depending on use case.
- Adam Beneschan (2008-01-09). "Pragma Pack vs. Convention C, portability issue?". comp.lang.ada. (Web link). Retrieved on 2008-05-27.
- Software Productivity Consortium (October 1995). Ada 95 Quality and Style Guide, "10.5.7 Packed Boolean Array Shifts"
- Software Productivity Consortium (October 1995). Ada 95 Quality and Style Guide, "10.6.3 Bit Operations on Modular Types"