Main Content

MISRA C:2012 Rule 8.1

Types shall be explicitly specified

Description

Rule Definition

Types shall be explicitly specified.

Rationale

In some circumstances, you can omit types from the C90 standard. In those cases, the int type is implicitly specified. However, the omission of an explicit type can lead to confusion. For example, in the declaration extern void foo (char c, const k);, the type of k is const int, but you might expect const char.

You might be using an implicit type in:

  • Object declarations

  • Parameter declarations

  • Member declarations

  • typedef declarations

  • Function return types

Polyspace Implementation

The rule checker flags situations where a function parameter or return type is not explicitly specified.

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

static foo(int a);  /* Non compliant */
static void bar(void);      /* Compliant */

In this example, the rule is violated because the return type of foo is implicit.

Check Information

Group: Declarations and Definitions
Category: Required
AGC Category: Required

Version History

Introduced in R2014b