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.FUNCMACRO : Function-Like Macro

Summary

A function-like macro is defined.

See also Macro Argument is both Mixed and Expanded.

Properties

Class Name Function-Like Macro
Significance style
Mnemonic LANG.PREPROC.FUNCMACRO
Categories
MisraC2025 MisraC2025:D.4.9 A function should be used in preference to a function-like macro where they are interchangeable
MisraC2023 MisraC2023:D.4.9 A function should be used in preference to a function-like macro where they are interchangeable
Misra2012 Misra2012:D.4.9 A function should be used in preference to a function-like macro where they are interchangeable
Misra2004 Misra2004:19.7 A function should be used in preference to a function-like macro
AUTOSARC++14 AUTOSARC++14:A16-0-1 The pre-processor shall only be used for unconditional and conditional file inclusion and include guards, and using the following directives: (1) #ifndef, (2) #ifdef, (3) #if, (4) #if defined, (5) #elif, (6) #else, (7) #define, (8) #endif, (9) #include.
MisraC++2008 MisraC++2008:16-0-4 Function-like macros shall not be defined.
MisraC++2023 MisraC++2023:19.0.2 Function-like macros shall not be defined
CERT-C CERT-C:PRE00-C Prefer inline or static functions to function-like macros
  CERT-C:PRE31-C Avoid side effects in arguments to unsafe macros
JSF++ JSF++:29 The #define pre-processor directive shall not be used to create inline macros. Inline functions shall be used instead.
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="Function-Like Macro"

Example

#define ONE 1                                       /* not function-like */
#define TWO (2)                                     /* not function-like */
#define THREE()(3)      /* 'Function-Like Macro' warning issued here */
#define FOUR(a)(4)      /* 'Function-Like Macro' warning issued here */
#define ADD(a,b)(a+b)   /* 'Function-Like Macro' warning issued here */

/* Macros do not need to be used in order to trigger 'Function-Like Macro' warnings. */

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/.