Skip to content

Commit 0305086

Browse files
authored
Merge pull request #3220 from TylerMSFT/twhitney-noreturn
touchup
2 parents 36f1ad6 + d2d894d commit 0305086

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

docs/c-language/noreturn.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
---
22
title: "_Noreturn keyword and noreturn macro (C11)"
33
description: "Describes the `_Noreturn` keyword and `noreturn` macro."
4-
ms.date: 10/16/2020
4+
ms.date: 10/19/2020
55
f1_keywords: ["_Noreturn_c", "noreturn"]
66
helpviewer_keywords: ["keywords [C]"]
77
---
88

99
# `_Noreturn` keyword and `noreturn` macro (C11)
1010

11-
The `_Noreturn` keyword was introduced in C11. It tells the compiler that the function it's applied to doesn't return. The compiler knows that the code following a call to a `_Noreturn` function is unreachable.
11+
The `_Noreturn` keyword was introduced in C11. It tells the compiler that the function it's applied to doesn't return to the caller. The compiler knows that the code following a call to a `_Noreturn` function is unreachable. An example of a function that doesn't return is [abort](../c-runtime-library/reference/abort.md). If there's a possibility for control flow to return to the caller, the function must not have the `_Noreturn` attribute.
1212

13-
A convenience macro, `noreturn`, provided in <stdnoreturn.h>, maps to the `_Noreturn` keyword.
13+
The keyword is typically used through the convenience macro, `noreturn`, provided in <stdnoreturn.h>, which maps to the `_Noreturn` keyword.
1414

1515
The primary benefits for using `_Noreturn` (or the equivalent `noreturn`) are making the intention of the function clear in the code for future readers, and detecting unintentionally unreachable code.
1616

17+
A function marked `noreturn` shouldn't include a return type because it doesn't return a value to the caller. It should be `void`.
18+
1719
## Example using `noreturn` macro and `_Noreturn `keyword
1820

1921
The following example demonstrates the `_Noreturn` keyword and the equivalent `noreturn` macro.
@@ -61,5 +63,6 @@ int main(void)
6163
## See also
6264
6365
[/std (Specify language standard version)](../build/reference/std-specify-language-standard-version.md)\
64-
[/W4 (Specify warning level)](../build/reference/compiler-option-warning-level.md)
65-
[C4702 warning](../error-messages\compiler-warnings\compiler-warning-level-4-c4702.md)
66+
[/W4 (Specify warning level)](../build/reference/compiler-option-warning-level.md)\
67+
[C4702 warning](../error-messages\compiler-warnings\compiler-warning-level-4-c4702.md)\
68+
[__declspec(noreturn)](../cpp/noreturn.md)

0 commit comments

Comments
 (0)