DoAssert
void DoAssert (int passed, const char fileName[], int lineNumber, const char message[]);
Purpose
This function is used to implement the Assert and AssertMsg macros.
The Assert macros are useful for notifying you of errors in your code during development. They should be called when a fatal programming error in your code has been detected. They will display a dialog box giving the line number and source filename where the error was detected and then abort the program.
You may want to redefine the Assert macros to do nothing if you are compiling a final release version of your program.
Liberal use of Asserts can find large numbers of bugs that would otherwise escape detection.
Example:
void SomeFunction (int numBytes)
{
/* numBytes must always be greater than zero. If it isn't, it indicates an error in programming. */
/* if numBytes is not greater than zero, then a dialog box will appear giving the filename and line number where this Assert is. When the dialog is dismissed, the program will be aborted. */
Assert (numBytes > 0);
/* rest of function goes here */
}
Parameters
Input | ||
Name | Type | Description |
passed | int | Specify 0 or select Off in the function panel to abort the program after displaying an error message. If you specify a nonzero value or select On in the function panel, the function does nothing. |
fileName | const char[] | The filename to display in the Assert dialog box if passed is not TRUE (non–zero). This parameter is filled in automatically when you use the Assert macro. |
lineNumber | int | The line number to display in the Assert dialog box if passed is not TRUE (non–zero). This parameter is filled in automatically when you use the Assert macro. |
message | const char[] | The message that the Assert dialog box will display. If 0 is passed, the message "Programming error detected." will be displayed. |
Return Value
None.
Additional Information
Library: Programmer's Toolbox
Include file: toolbox\toolbox.h
LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later