AUTOSAR C++14 Rule A9-6-1
Data types used for interfacing with hardware or conforming to communication protocols shall be trivial, standard-layout and only contain members of types with defined sizes
Description
Rule Definition
Data types used for interfacing with hardware or conforming to communication protocols shall be trivial, standard-layout and only contain members of types with defined sizes.
Rationale
When interfacing with hardware or when conforming to communication protocols, the layout of the data type you use must be consistent and standardized. For these tasks, use data types with layout and size that are not dependent on your hardware or software.
Types with well defined sizes are listed in the header <cstdint>
. Examples of such data type includes types such as int16_8
and int32_t
. This list excludes types such as bool
, wchar_t
, and pointers. Avoid using excluded types when interfacing with hardware or when conforming to communication protocols.
Using enumerations are allowed only when the underlying data types of the
enum
has a well defined size. Using bitfields for these tasks are
allowed only when the underlying type has a well defined size,
Polyspace Implementation
Polyspace® raises a violation of this rule if you use a data type other than these two in a bit field:
Enumeration
Unsigned integral type
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Classes |
Category: Required, Partially automated |
Version History
Introduced in R2019a