Skip to content

Tweaks for C6030 warning page #5203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions docs/code-quality/c6030.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,32 @@ f1_keywords: ["C6030", "USE_ATTRIBUTE_NORETURN", "__WARNING_USE_ATTRIBUTE_NORETU
helpviewer_keywords: ["C6030"]
---

# Warning C6030
# Warning C6030

> Use attribute [[noreturn]] over __declspec(noreturn) in function '*function-name*'

## Remarks

This warning suggests using the C++11 standard attribute `[[noreturn]]` in place of the declspec variant `__declspec(noreturn)`. The standard attribute provides better cross-platform support because it doesn't rely on language extensions.
This warning suggests using the C++11 standard attribute [`[[noreturn]]`](../cpp/attributes.md#noreturn) in place of the declspec variant [`__declspec(noreturn)`](../cpp/noreturn.md). The standard attribute provides better cross-platform support because it doesn't rely on language extensions.

This warning is off by default and isn't part of the `All Rules` rule set. To enable this warning, it must be added to the rule set file being used.

This check is available in Visual Studio 2022 version 17.0 and later versions.

Code analysis name: `USE_ATTRIBUTE_NORETURN`

## Example

The following code generates C6030:

```cpp
__declspec(noreturn) void TerminateApplication();

__declspec(noreturn) void terminate_application();
```

Fix the issue by using the `[[noreturn]]` attribute:

```cpp
[[ noreturn ]] void TerminateApplication();

[[noreturn]] void terminate_application();
```

## See also
Expand Down