Main Content
AUTOSAR C++14 Rule A7-1-9
A class, structure, or enumeration shall not be declared in the definition of its type
Description
Rule Definition
A class, structure, or enumeration shall not be declared in the definition of its type.
Rationale
This rule forbids declarations of objects in the same statement as the definition of its
type. For instance, the following statement defines a structure type
Record
while also defining an object of that
type:
struct Record { std::uint32_t* elems; std::uint8_t size; } someRecord;
Polyspace Implementation
The rule checker reports a violation on objects that are defined in the same statement as their type definitions.
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: Declaration |
Category: Required, Automated |
Version History
Introduced in R2019a