Main Content

AUTOSAR C++14 Rule M3-2-3

A type, object or function that is used in multiple translation units shall be declared in one and only one file

Description

Rule Definition

A type, object or function that is used in multiple translation units shall be declared in one and only one file.

Rationale

If you declare an identifier in a header file, you can include the header file in any translation unit where the identifier is defined or used. In this way, you ensure consistency between:

  • The declaration and the definition.

  • The declarations in different translation units.

The rule enforces the practice of declaring external objects or functions in header files.

Troubleshooting

If you expect a rule violation but Polyspace® does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.

Check Information

Group: Basic Concepts
Category: Required, Automated

Version History

Introduced in R2019a