主要内容

MISRA C:2025 Rule 5.9

R2026b

Identifiers that define objects or functions with internal linkage should be unique

Since R2026b

Description

This checker is deactivated in a default Polyspace® as You Code™ analysis. See Checkers Deactivated in Polyspace as You Code Analysis (Polyspace as You Code).

Rule Definition

Identifiers that define objects or functions with internal linkage should be unique 1 .

Rationale

Identifiers that have internal linkage are accessible only in the translation unit where they are declared. These identifiers are typically declared as static. If such identifiers are nonunique, the code might become difficult to understand and lead to unexpected results.

Polyspace Implementation

Polyspace flags the static variable names that are nonunique across all translation units.

Troubleshooting

If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.

Examples

expand all

#include<stdint.h>
#include <assert.h>
static int testGlobal;
void foo(){
static char testGlobal;//Noncompliant	
if(1){
	static char testGlobal;//Noncompliant
}
}

In this example, the identifier testGlobal is used for declaring three variables in three different scopes. Because the identifiers are static and share a nonunique name, Polyspace flags the repetitions of the identifier.

Check Information

Group: Identifiers
Category: Advisory
AGC Category: Disapplied
PQL Name: std.misra_c_2025.R5_9

Version History

Introduced in R2026b


1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.

The MISRA coding standards referenced in the Polyspace Bug Finder™ documentation are from the following MISRA standards:

  • MISRA C:2004

  • MISRA C:2012

  • MISRA C:2023

  • MISRA C:2025

  • MISRA C++:2008

  • MISRA C++:2023

MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.