411 REFERENCE · Wikibooks
Ada Programming/Pragmas/Pack:3
Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.
Exact data representation
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. Pragma Pack vs. Convention C, portability issue? Adam Beneschan 2008-01-09 comp.lang.ada 3f729fc9-708f-49a5-82a5-b2d82038a47c@s12g2000prg.googlegroups.com http://groups.google.es/group/comp.lang.ada/msg/6698960624779ec7 2008-05-27 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
Although in Ada 83 packed boolean arrays were used for bit-wise operations,Software Productivity Consortium (October 1995). Ada 95 Quality and Style Guide, "10 5 7 Packed Boolean Array Shifts" since Ada 95 modular types are more adequate for these operations.Software Productivity Consortium (October 1995). Ada 95 Quality and Style Guide, "10 6 3 Bit Operations on Modular Types" 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.Pack