Admin Production ni-theme
Current Publication

SetBreakOnProtectionErrors

LabWindows/CVI

SetBreakOnProtectionErrors

int SetBreakOnProtectionErrors (int newState);

Purpose

If you enable debugging, LabWindows/CVI uses information it gathers from compiling your source code to make extensive run-time checks to protect your program. When it encounters a protection error at run-time, LabWindows/CVI displays a dialog box and suspends execution.

The following lists examples of protection errors.

  • Dereferencing an invalid pointer value in source code.
  • Attempting, in source code, to read or write beyond the end of an array.
  • Making a function call, in source code, in which an array is smaller than the function expects.
  • Performing pointer arithmetic, in source code, that generates an invalid address.

You can use SetBreakOnProtectionErrors to prevent LabWindows/CVI from displaying the dialog box and suspending execution when it encounters a protection error. In general, it is better not to disable the break on protection errors feature. Nevertheless, you might want to disable the option temporarily around a line of code for which LabWindows/CVI erroneously reports a protection error. This function changes the setting for the thread that calls this function.

If you disable run-time checking, SetBreakOnProtectionErrors has no effect. LabWindows/CVI never reports run-time errors when you disable run-time checking. Run-time checking is enabled when you set the debugging level in the Build Options dialog box of the Workspace window to Standard or Extended, and select a debug configurationdebug configuration.

Note    If an invalid memory access generates a processor exception, LabWindows/CVI reports the error and terminates your program regardless of the debugging level or the state of the break on protection errors feature.

Example Code

int oldValue;
oldValue = SetBreakOnProtectionErrors (0);
/* Statement that erroneously reports an error */
SetBreakOnProtectionErrors (oldValue);

Parameters

Input
Name Type Description
newState int Specifies the new break-on-protection-errors state.

Specify a nonzero value or select Enabled in the function panel to display a dialog box and suspend execution when a National Instruments library function reports a protection error, if you enable debugging.

Specify 0 or select Disabled in the function panel if you do not want to suspend execution.

If you disable debugging, this parameter has no effect.

Return Value

Name Type Description
previousState int Previous state of the Break on protection errors feature.

Code Description
1 Previously enabled.
0 Previously disabled, or debugging is disabled.

Additional Information

Library: Utility Library

Include file: utility.h

LabWindows/CVI compatibility: LabWindows/CVI 4.0 and later