Skip to content

Commit b8a74ee

Browse files
author
Steve Wishnousky
authored
Acrolinxification
This thing is wild.
1 parent cccbfea commit b8a74ee

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

docs/c-runtime-library/reference/assert-macro-assert-wassert.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,37 +50,37 @@ The line number in the source file of the failed assertion.
5050

5151
The `assert` macro is typically used to identify logic errors during program development. Use it to stop program execution when unexpected conditions occur by implementing the *expression* argument to evaluate to **`false`** only when the program is operating incorrectly. Assertion checks can be turned off at compile time by defining the macro **NDEBUG**. You can turn off the `assert` macro without modifying your source files by using a **/DNDEBUG** command-line option. You can turn off the `assert` macro in your source code by using a `#define NDEBUG` directive before \<assert.h> is included.
5252

53-
The `assert` macro prints a diagnostic message when *expression* evaluates to **`false`** (0) and calls [`abort`](abort.md) to terminate program execution. No action is taken if *expression* is **`true`** (nonzero). The diagnostic message includes the failed expression, the name of the source file and line number where the assertion failed.
53+
The `assert` macro prints a diagnostic message when *expression* evaluates to **`false`** (0) and calls [`abort`](abort.md) to stop program execution. No action is taken if *expression* is **`true`** (nonzero). The diagnostic message includes the failed expression, the name of the source file and line number where the assertion failed.
5454

55-
The diagnostic message is printed in wide (`wchar_t`) characters. Thus, it will work as expected even if there are Unicode characters in the expression.
55+
The diagnostic message is printed in wide (`wchar_t`) characters. Therefore, it will work as expected even if there are Unicode characters in the expression.
5656

57-
The destination of the diagnostic message depends on the type of application that called the routine. Console applications receive the message through **stderr**. In a Windows-based application, `assert` calls the Windows [MessageBox](/windows/win32/api/winuser/nf-winuser-messagebox) function to create a message box to display the message with three buttons: **Abort**, **Retry**, and **Ignore**. If the user clicks **Abort**, the program aborts immediately. If the user clicks **Retry**, the debugger is called and the user can debug the program if just-in-time (JIT) debugging is enabled. If the user clicks **Ignore**, the program will continue with normal execution. Note that clicking **Ignore** when an error condition exists can result in undefined behavior since preconditions of the calling code were not met.
57+
The destination of the diagnostic message depends on the type of application that called the routine. Console applications receive the message through **stderr**. In a Windows-based application, `assert` calls the Windows [MessageBox](/windows/win32/api/winuser/nf-winuser-messagebox) function to create a message box to display the message with three buttons: **Abort**, **Retry**, and **Ignore**. If the user clicks **Abort**, the program aborts immediately. If the user clicks **Retry**, the debugger is called and the user can debug the program if just-in-time (JIT) debugging is enabled. If the user clicks **Ignore**, the program will continue with normal execution. Clicking **Ignore** when an error condition exists can result in undefined behavior since preconditions of the calling code weren't met.
5858

5959
To override the default output behavior regardless of the app type, call [`_set_error_mode`](set-error-mode.md) to select between the output-to-stderr and display-dialog-box behavior.
6060

61-
After `assert` displays its message, it calls [`abort`](abort.md) which displays a dialog box with **Abort**, **Retry**, and **Ignore** buttons. [`abort`](abort.md) exits the program, so neither the **Retry** nor **Ignore** button will resume execution following the `assert` call. If `assert` displayed a dialog box, the [`abort`](abort.md) dialog box is not shown. The only time the [`abort`](abort.md) dialog box is shown is when `assert` sends its output to stderr.
61+
After `assert` displays its message, it calls [`abort`](abort.md), which displays a dialog box with **Abort**, **Retry**, and **Ignore** buttons. [`abort`](abort.md) exits the program, so the **Retry** and **Ignore** button won't resume program execution following the `assert` call. If `assert` displayed a dialog box, the [`abort`](abort.md) dialog box isn't shown. The only time the [`abort`](abort.md) dialog box is shown is when `assert` sends its output to stderr.
6262

63-
This means that a dialog box is always displayed following an `assert` call in debug mode. The behavior of each button is captured in the below table.
63+
As a consequence of the above behavior, a dialog box is always displayed following an `assert` call in debug mode. The behavior of each button is captured in the below table.
6464

6565
|Error mode|Output to stderr (Console/_OUT_TO_STDERR)|Display Dialog Box (Windows/_OUT_TO_MSGBOX)|
6666
|----------|----------------|------------------|
6767
|Abort|Exit immediately with exit code 3|Exit immediately with exit code 3|
6868
|Retry|Break into debugger during `abort`|Break into debugger during `assert`|
69-
|Ignore|Finish exiting via `abort`|Continue program as though the assert did not fire (may result in undefined behavior since preconditions of the calling code were not met)|
69+
|Ignore|Finish exiting via `abort`|Continue program as though the assert didn't fire (may result in undefined behavior since preconditions of the calling code weren't met)|
7070

7171
For more information about CRT debugging, see [CRT Debugging Techniques](/visualstudio/debugger/crt-debugging-techniques).
7272

73-
The `_assert` and `_wassert` functions are internal CRT functions. They help minimize the code required in your object files to support assertions. We do not recommend that you call these functions directly.
73+
The `_assert` and `_wassert` functions are internal CRT functions. They help minimize the code required in your object files to support assertions. We don't recommend that you call these functions directly.
7474

75-
The `assert` macro is enabled in both the release and debug versions of the C run-time libraries when **NDEBUG** is not defined. When **NDEBUG** is defined, the macro is available but does not evaluate its argument and has no effect. When it is enabled, the `assert` macro calls `_wassert` for its implementation. Other assertion macros, [_ASSERT](assert-asserte-assert-expr-macros.md), [_ASSERTE](assert-asserte-assert-expr-macros.md) and [_ASSERT_EXPR](assert-asserte-assert-expr-macros.md), are also available, but they only evaluate the expressions passed to them when the [_DEBUG](../../c-runtime-library/debug.md) macro has been defined and when they are in code linked with the debug version of the C run-time libraries.
75+
The `assert` macro is enabled in both the release and debug versions of the C run-time libraries when **NDEBUG** isn't defined. When **NDEBUG** is defined, the macro is available but doesn't evaluate its argument and has no effect. When it's enabled, the `assert` macro calls `_wassert` for its implementation. Other assertion macros, [_ASSERT](assert-asserte-assert-expr-macros.md), [_ASSERTE](assert-asserte-assert-expr-macros.md) and [_ASSERT_EXPR](assert-asserte-assert-expr-macros.md), are also available, but they only evaluate the expressions passed to them when the [_DEBUG](../../c-runtime-library/debug.md) macro has been defined and when they are in code linked with the debug version of the C run-time libraries.
7676

7777
## Requirements
7878

7979
|Routine|Required header|
8080
|-------------|---------------------|
8181
|`assert`, `_wassert`|\<assert.h>|
8282

83-
The signature of the `_assert` function is not available in a header file. The signature of the `_wassert` function is only available when the **NDEBUG** macro is not defined.
83+
The signature of the `_assert` function isn't available in a header file. The signature of the `_wassert` function is only available when the **NDEBUG** macro isn't defined.
8484

8585
## Example
8686

@@ -125,7 +125,7 @@ Analyzing string '(null)'
125125
Assertion failed: string != NULL, file crt_assert.c, line 25
126126
```
127127

128-
After the assertion failure, depending on the version of the operating system and run-time library, you may see a message box that contains something like the following:
128+
After the assertion failure, depending on the version of the operating system and run-time library, you may see a message box that contains something similar to:
129129

130130
```Output
131131
A problem caused the program to stop working correctly. Windows will close the program and notify you if a solution is available.

0 commit comments

Comments
 (0)