# 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 Build»Configuration»Debug.

| 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

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

## Parameters

Input
Name | Type | Description
newState | integer | Determines whether the Break on protection errors feature is enabled on disabled. Pass a nonzero value to enable. Pass zero to disable. If debugging is disabled, this parameter has no effect.

## Return Value

Name | Type | Description
oldState | integer | Previous state of the Break on protection errors feature.
Code | Description
1 | Previously enabled.
0 | Previously disabled, or debugging is disabled.