# V2657. MISRA. Obsolescent language features should not be used.

This diagnostic rule is based on the MISRA (Motor Industry Software Reliability Association) software development guidelines.

This diagnostic rule is relevant only for C.

The diagnostic rule requires avoiding the use of language constructs declared obsolete in Sections 6.11 and 7.33 of the C language standards because such designs may result in unintended behavior and are usually replaced by safer and more effective alternatives.

The following table lists the obsolete features for which the diagnostic rule is issued:

N | Obsolete language features | Diagnostic rule | Language standard
--- | --- | --- | ---
1 | A function or object declared once with an internal linkage type also have an internal linkage when redeclared or redefined. Therefore, the `static` specifier should be explicitly specified in each declaration and definition. | V2608 | C99, C11, C18
2 | Storage-class specifiers (`extern`, `static`, etc.) are not placed at the beginning of the declaration and definition. | V2657 | C99, C11, C18
3 | Declaring a function using empty parentheses. | V2601 | C99, C11, C18
4 | Using K&R-style function declarations and unnamed function parameters. | V2601 | C99, C11, C18
5 | Using the `ATOMIC_VAR_INIT` macro defined in `stdatomic.h`. | V2657 | C18
6 | Overriding the `bool`, `true`, and `false` macros defined in `stdbool.h`. | V2573 | C99, C11, C18
7 | Using the `gets()` function defined in `stdio.h`. | V2600 | C99
8 | Using the `ungetc()` function on a binary stream where the file position identifier is zero. | V2600 | C99, C11, C18
9 | Using the `realloc()` function defined in `stdlib.h` with the `size` argument equal to zero. | V2511 | C18

The V2657 diagnostic rule operates in conjunction with diagnostic rules listed in the second column of the table to provide comprehensive analysis.

Look at two examples that are covered by this rule but not covered by others.

Example N1. The specifier is not placed at the beginning of the variable declaration:

    int static var;

The fixed code:

    static int var;

Example N2. Using `ATOMIC_VAR_INIT`:

    atomic_int guide = ATOMIC_VAR_INIT(42);

The fixed code:

    _Atomic int guide = 42;

More examples can be found in the documentation for the corresponding diagnostic rules listed in the table.

This diagnostic is classified as:

MISRA-C-2023-1.5