Rule A3-9-1 (required, implementation, automated)

Fixed width integer types from , indicating the size and signedness, shall be used in place of the basic numerical types.

Rationale

The basic numerical types of char, int, short, long are not supposed to be used, specific-length types from header need be used instead. Fixed width integer types are: std::int8_t std::int16_t

std::int32_t std::int64_t std::uint8_t std::uint16_t std::uint32_t std::uint64_t

Exception

The wchar_t does not need a typedef as it always maps to a type that supports wide characters.

Example

//% $Id: A3-9-1.cpp 289436 2017-10-04 10:45:23Z michal.szczepankiewicz $
#include <cstdint>
void F()
{
std::int32_t
i1 = 5;
// Compliant
int i2 = 10;
// Non-compliant
std::int64_t i3 = 250; // Compliant
long int i4
= 50;
// Non-compliant
std::int8_t
i5 = 16;
// Compliant
char
i6 = 23;
// Non-compliant
}

See also

MISRA C++ 2008 [7]: Rule 3-9-2 typedefs that indicate size and signedness should be used in place of the basic numerical types.