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.NBPE : Non-Boolean Preprocessor Expression

Summary

The controlling expression of a preprocessor #if or #elif directive is evaluated, and has a value other than 1 (one) or 0 (zero).

Controlling expressions that are not evaluated do not have any influence on the program and so do not trigger warnings of this class.

Properties

Class Name Non-Boolean Preprocessor Expression
Significance style
Mnemonic LANG.PREPROC.NBPE
Categories
MisraC2025 MisraC2025:20.8 The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1
MisraC2023 MisraC2023:20.8 The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1
Misra2012 Misra2012:20.8 The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1
POW10 POW10:8 Limit the use of the preprocessor to file inclusion and simple macros.
JPL JPL:20 Make only very limited use of the C pre-processor.
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="Non-Boolean Preprocessor Expression"

Example

#define ONE 1
#define TWO 2

#if TWO           /* 'Non-Boolean Preprocessor Expression' warning issued here. */
/* ... */
#endif 

#if TWO > ONE                 /* Boolean */
/* ... */
#endif 


#if !ONE                      /* Boolean */
/* ... */
#if TWO                       /* Not evaluated: !ONE always evaluates to FALSE. */
/* ... */
#endif
/* ... */
#endif 

#if ONE                       /* Boolean */
/* ... */
#elif TWO                     /* Not evaluated: ONE always evaluates to TRUE. */
/* ... */
#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/.