Skip to content

Repo sync for protected CLA branch #4476

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 6 commits into from
Mar 22, 2023
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
40 changes: 40 additions & 0 deletions docs/code-quality/c6030.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: Warning C6030
description: "Describes C++ Code Analysis warning C6030 and how to resolve it."
ms.date: 03/10/2023
f1_keywords: ["C6030", "USE_ATTRIBUTE_NORETURN", "__WARNING_USE_ATTRIBUTE_NORETURN"]
helpviewer_keywords: ["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 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();

```

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

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

```

## See also

[Use Rule Sets to Specify the C++ Rules to Run](./using-rule-sets-to-specify-the-cpp-rules-to-run.md)