Main Content

AUTOSAR C++14 Rule A3-1-3

Implementation files, that are defined locally in the project, should have a file name extension of ".cpp"

Description

Rule Definition

Implementation files, that are defined locally in the project, should have a file name extension of ".cpp".

Rationale

Some compilers allow for various file extensions for C++ implementation files. Typically, implementation files have a .cpp extension. Using a standard .cpp extension for implementation files in your project clarifies which files are implementation files.

Polyspace Implementation

Polyspace® reports a violation of this rule if an implementation source file has an extension other than .cpp. The file extension is not case sensitive if you set the option -dos.

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

expand all

In this example, the implementation file has an extension .c, which violates this rule.

Header file:

/* header.h */
extern int var;
extern void func1(void);   

Implementation file:

/* Noncompliant */
/* module.c */
#include "header.h"

extern void func2(void);   

/* Definitions */
int var = 0;
void func1(void) {}

Check Information

Group: Basic Concepts
Category: Advisory, Automated

Version History

Introduced in R2019a