Standard C Libraries
2.3
<ASSERT.H> DIAGNOSTICS
The header file assert.h consists of a single macro that is useful for debugging logic
errors in programs. By using the assert statement in critical locations where certain
conditions should be true, the logic of the program may be tested.
Assertion testing may be turned off without removing the code by defining NDEBUG
before including <assert.h> . If the macro NDEBUG is defined, assert() is ignored and
no code is generated.
assert
Description:
Include:
Prototype:
Argument:
Remarks:
Example:
? 2008 Microchip Technology Inc.
If the expression is false, an assertion message is printed to stderr and
the program is aborted.
<assert.h>
void assert(int expression );
expression The expression to test.
The expression evaluates to zero or non-zero. If zero, the assertion
fails, and a message is printed to stderr. The message includes the
source file name ( __ FILE __ ), the source line number ( __ LINE __ ),
the expression being evaluated and the message. The macro then calls
the function abort() . If the macro _VERBOSE_DEBUGGING is defined,
a message will be printed to stderr each time assert() is called.
#include <assert.h> /* for assert */
int main(void)
{
int a;
a = 2 * 2;
assert(a == 4); /* if true-nothing prints */
assert(a == 6); /* if false-print message */
/* and abort */
}
Output:
sampassert.c:9 a == 6 -- assertion failed
ABRT
with _VERBOSE_DEBUGGING defined:
sampassert.c:8 a == 4 -- OK
sampassert.c:9 a == 6 -- assertion failed
ABRT
DS51456E-page 13
相关PDF资料
SW006015 C COMPILER MPLAB C32
SW300003-EVAL LIBRARY SOFT MODEM-EVAL ONLY
SW300010-EVAL SPEECH RECOG LIBRARY-EVAL ONLY
SW300040-EVAL LIBRARY NOISE SUPPR-EVAL ONLY
SW300060-EVAL LIBRARY ACOUSTIC ECHO-EVAL ONLY
SW300070-EVAL SOFTWARE LIBR ENC/DEC EVAL ONLY
SW500012 HI-TECH C PRO FOR PIC32
SY87701LHI-EVAL BOARD EVAL SY87701 EXPERIMENT
相关代理商/技术参数
SW006013 制造商:Microchip Technology Inc 功能描述:MPLAB C Compiler for dsPIC DSCs
SW006014 功能描述:开发软件 C Compiler for PIC24 MCU RoHS:否 制造商:Atollic Inc. 产品:Compilers/Debuggers 用于:ARM7, ARM9, Cortex-A, Cortex-M, Cortex-R Processors
SW006015 功能描述:开发软件 MPLAB C32 C Compiler RoHS:否 制造商:Atollic Inc. 产品:Compilers/Debuggers 用于:ARM7, ARM9, Cortex-A, Cortex-M, Cortex-R Processors
SW006021-1 制造商:Microchip Technology 功能描述:MPLAB XC8 STANDARD COMPILER 制造商:Microchip Technology Inc 功能描述:COMPILER MPLAB XC8 STD 制造商:Microchip Technology Inc 功能描述:COMPILER MPLAB XC8 STANDARD 制造商:Microchip Technology Inc 功能描述:COMPILER, MPLAB XC8, STANDARD 制造商:Microchip Technology Inc 功能描述:MPLAB XC8 ANSI C Compiler for the PIC10 (12),(16),(18) (Workstation License) 制造商:Microchip Technology Inc 功能描述:MPLAB XC8 Standard Compiler 制造商:Microchip Technology Inc 功能描述:OPTOCOUPLERS; Core Architecture:PIC; Software Edition:Standard
SW006021-1N 制造商:Microchip Technology 功能描述:MPLAB XC8 STANDARD COMPILER (F 制造商:Microchip Technology Inc 功能描述:MPLAB XC8 STANDARD COMPILER (FLOATING LICENSE) - Boxed Product (Development Kits) 制造商:Microchip Technology Inc 功能描述:COMPILER MPLAB XC8 STD FLOAT LIC 制造商:Microchip Technology Inc 功能描述:MPLAB XC8 Standard Compiler (Fltng Lic)
SW006021-2 制造商:Microchip Technology 功能描述:MPLAB XC8 PRO COMPILER WORKSTATION LICENSE 制造商:Microchip Technology Inc 功能描述:MPLAB XC8 PRO COMPILER - Boxed Product (Development Kits) 制造商:Microchip Technology Inc 功能描述:COMPILER MPLAB XC8 PRO 制造商:Microchip Technology Inc 功能描述:COMPILER, MPLAB XC8, PRO 制造商:Microchip Technology Inc 功能描述:MPLAB XC8 ANSI PRO Compiler for the PIC10 (12),(16),(18) (Workstation License) 制造商:Microchip Technology Inc 功能描述:MPLAB XC8 PRO Compiler 制造商:Microchip Technology Inc 功能描述:SOFTWARE TOOL, MPLAB XC8 PRO COMPILER; Core Architecture:PIC; Supported Families:PIC10, PIC16, PIC18; Software Edition:Linux; License Type:Floating - node; No. of User Licenses:1; Supported Hosts:-
SW006021-2C 制造商:Microchip Technology Inc 功能描述:COMPILER MPLAB XC8 PRO CHI
SW006021-2N 功能描述:开发软件 MPLAB XC8 PRO Compiler (Fltng Lic) RoHS:否 制造商:Atollic Inc. 产品:Compilers/Debuggers 用于:ARM7, ARM9, Cortex-A, Cortex-M, Cortex-R Processors