Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This macro asserts an expression and produces a DebugBreakif the expression is FALSE.

Syntax

#define ASSERT(
exp)

Parameters

Exp

A Boolean expression used to determine when a DebugBreakis called.

Return Value

None.

Remarks

This macro may be used to check the value of a Boolean expression and produce a DebugBreakif the expression evaluates FALSE. This macro also prints a debug message with the file name and line number where the assertion failed.

Call this macro to validate invariants in your code. For example:

Copy Code
 ASSERT(dwCurrentNumberOfItems < dwMaxNumberOfItems);

Will print output like this:

Copy Code
 Unknown: DEBUGCHK failed in file
C:\WINCE500\Programs\MyProgram\.\main.c at line 32

This assertion is only present in Debug and builds; it does nothing on Retail and ship builds.

The ASSERTmacro does not assume that dpCurSettingsis present. Use ASSERTwithin modules that do not define dpCurSettings, and DEBUGCHKwithin modules that do define dpCurSettings.

To print an additional string whenever your assertion fails, use ASSERTMSG.

Requirements

Header dbgapi.h
Windows Embedded CE Windows CE 2.10 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also