6.1.3 __conditional_software_breakpoint Macro
Trigger a software breakpoint if the argument is false.
Include
<assert.h>
Prototype
void __conditional_software_breakpoint(scalar
expression);
Argument
expression
- The expression to test.
Remarks
The expression evaluates to zero or non-zero. If non-zero, the macro evaluates to the
do-nothing expression, ((void)0)
. If zero, a software breakpoint is
triggered and execution will be suspended. If the target device does not support
software breakpoints, a compiler error is triggered.
If the macro NDEBUG
(see NDEBUG Macro) is defined or the
macro __DEBUG
is not defined at the point where
<assert.h>
is included, the
__conditional_software_breakpoint()
macro will evaluate to a void
expression, ((void)0)
, and not suspend program execution. Inclusion of
<assert.h>
can occur multiple times, even in the same source
file, and the action of the __conditional_software_breakpoint()
macro
for each inclusion will be based on the state of NDEBUG
and
__DEBUG
at the point at which that inclusion takes place. Note that
the __DEBUG
macro is automatically set by the MPLAB X IDE when
performing a debug (as opposed to a production) build.
Example
#include <xc.h>
int main(void)
{
int a;
a = 4;
#define NDEBUG /* negate debugging - disable __conditional_software_breakpoint() functionality */
#include <assert.h>
__conditional_software_breakpoint(a == 6); /* no action performed, even though expression is false */
#undef NDEBUG /* ensure __conditional_software_breakpoint() is active */
#include <assert.h>
a = 7;
__conditional_software_breakpoint(a == 7); /* true - no action performed */
__conditional_software_breakpoint(a == 8); /* false - suspend execution for debug builds */
}