JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
C and C++


LANG.PREPROC.ICONST : Inappropriate Argument to Integer Constant Macro

Summary

The argument to an integer constant macro:

See also Use of <stdint.h> Small Integer Constant Macro.

Properties

Class Name Inappropriate Argument to Integer Constant Macro
Significance reliability
Mnemonic LANG.PREPROC.ICONST
Categories
MisraC2025 MisraC2025:7.5 The argument of an integer constant macro shall have an appropriate form
MisraC2023 MisraC2023:7.5 The argument of an integer constant macro shall have an appropriate form
Misra2012 Misra2012:7.5 The argument of an integer constant macro shall have an appropriate form
Availability Available for C and C++.
Enabling Checks for this warning class are disabled by default. To enable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += allow class="Inappropriate Argument to Integer Constant Macro"

Example

#include <stdint.h>

uint32_t g1 = UINT32_C(1);               /* ok */

uint32_t g2 = UINT32_C(-1);  /* 'Inappropriate Argument to Integer Constant Macro' warning issued here
                              * - macro name UNIT32_C indicates a 32-bit unsigned integer
                              * - argument -1 is not representable as a 32-bit unsigned integer
                              */


/* These statements will cause errors in many compilers.
 * We guard them with "#ifdef __CODESONAR__ ... #endif" so that they
 * are preprocessed out by the native compiler (so the example can be compiled)
 * but still observed by the CodeSonar analysis.
 */

#ifdef __CODESONAR__

uint32_t g3 = UINT32_C(1u);  /* 'Inappropriate Argument to Integer Constant Macro' warning issued here
                              * - argument 1u has a literal suffix
                              */

uint32_t g4 = UINT32_C(1.0); /* 'Inappropriate Argument to Integer Constant Macro' warning issued here
                              * - argument is not an integer
                              */

uint32_t g5 = UINT32_C(g1);  /* 'Inappropriate Argument to Integer Constant Macro' warning issued here
                              * - argument is not a literal
                              */
#endif

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.

 

To report problems with this documentation, please visit https://support.codesecure.com/.