SOM Assert: Difference between revisions
Appearance
mNo edit summary |
mNo edit summary |
||
Line 16: | Line 16: | ||
==Remarks== | ==Remarks== | ||
The SOM_Assert macro is used to place boolean assertions in a program: | The SOM_Assert macro is used to place boolean assertions in a program: | ||
* If condition is FALSE, and errorCode indicates a warning-level error and | * If condition is FALSE, and errorCode indicates a warning-level error and SOM_WarnLevel is set to be greater than zero, then a warning message is output. | ||
* If condition is FALSE and errorCode indicates a fatal error, an error message is output and the process is terminated. | * If condition is FALSE and errorCode indicates a fatal error, an error message is output and the process is terminated. | ||
* If condition is TRUE and SOM_AssertLevel is set to be greater than zero, then an informational message is output. | * If condition is TRUE and SOM_AssertLevel is set to be greater than zero, then an informational message is output. | ||
Line 38: | Line 38: | ||
==Related== | ==Related== | ||
;Macros | |||
* SOM_Expect | * SOM_Expect | ||
*[[SOM_Test]] | *[[SOM_Test]] |
Latest revision as of 16:27, 17 December 2022
This macro asserts that a boolean condition is true.
Syntax
boolean condition; long errorCode; SOM_Assert(condition, errorCode);
Parameters
- condition (boolean)
- A boolean expression that is expected to be TRUE (nonzero).
- errorCode (long)
- The integer error code for the error to be raised if condition is FALSE.
Return Code
Remarks
The SOM_Assert macro is used to place boolean assertions in a program:
- If condition is FALSE, and errorCode indicates a warning-level error and SOM_WarnLevel is set to be greater than zero, then a warning message is output.
- If condition is FALSE and errorCode indicates a fatal error, an error message is output and the process is terminated.
- If condition is TRUE and SOM_AssertLevel is set to be greater than zero, then an informational message is output.
External (Global) Data
long SOM_WarnLevel; /* default = 0 */ long SOM_AssertLevel; /* default 0 */
Expansion
If condition is FALSE, and errorCode indicates a warning-level error and SOM_WarnLevel is set to be greater than zero, then a warning message is output. If condition is FALSE and errorCode indicates a fatal error, an error message is output and the process is terminated. If condition is TRUE and SOM_AssertLevel is set to be greater than zero, then an information message is output.
Example Code
#include <som.h> main() { SOM_WarnLevel = 1; SOM_Assert(2==2, 29); {
Related
- Macros