Skip to content

Commit 944d587

Browse files
Updated C28213
Updated to the new format
1 parent 1ebdfed commit 944d587

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

docs/code-quality/c28213.md

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,56 @@
11
---
22
description: "Learn more about: C28213"
33
title: C28213
4-
ms.date: 11/04/2016
4+
ms.date: 09/08/2022
55
ms.topic: reference
6-
f1_keywords: ["C28213"]
6+
f1_keywords: ["C28213", "BAD_USEHEADER", "__WARNING_BAD_USEHEADER"]
77
helpviewer_keywords: ["C28213"]
88
ms.assetid: e141a12a-4c46-47eb-aa9d-a6444472cfaa
99
---
10-
# C28213
10+
# Warning C28213
1111

12-
> warning C28213: The `_Use_decl_annotations_` annotation must be used to reference, without modification, a prior declaration.
12+
> The `_Use_decl_annotations_` annotation must be used to reference, without modification, a prior declaration.
13+
14+
## Remarks
1315

1416
`_Use_decl_annotations_` tells the compiler to use the annotations from an earlier declaration of the function. If no earlier declaration can be found, or if the current declaration makes changes to the annotations than this warning is emitted.
1517

18+
Code analysis name: BAD_USEHEADER
19+
1620
## Example
1721

22+
The following code generates C28160. The `buffer` parameter annotation does not match between the two files.
23+
24+
*From example.h:*
25+
1826
```cpp
19-
// from example.h
2027
void example_func(_Out_writes_(n) char* buffer, int n);
28+
```
29+
30+
*From example.cpp:*
2131
22-
// from example.cpp
32+
```cpp
2333
_Use_decl_annotations_
2434
void example_func(_Out_writes_z_(n) char* buffer, int n)
2535
{
26-
// ...
27-
buffer[n] = '\0';
36+
buffer[n] = '\0';
2837
}
2938
```
3039

31-
The `buffer` parameter annotation does not match between the two files. This can be fixed by either changing the annotation so they match at all locations, or by removing all annotations except `_Use_decl_annotations_` from the function definition. In this example `_Out_writes_z_` appears to be correct so we will move that to the function declaration in the header file.
40+
This can be fixed by either changing the annotation so they match at all locations, or by removing all annotations except `_Use_decl_annotations_` from the function definition. In this example, `_Out_writes_z_` appears to be correct so we will move that to the function declaration in the header file. The following code resolves this warning:
3241

33-
```cpp
42+
*From example.h:*
3443

35-
// from example.h
44+
```cpp
3645
void example_func(_Out_writes_z_(n) char* buffer, int n);
46+
```
3747
38-
// from example.cpp
48+
*From example.cpp:*
49+
50+
```cpp
3951
_Use_decl_annotations_
40-
void example_func(char* buffer, int n)
52+
void example_func(_Out_writes_z_(n) char* buffer, int n)
4153
{
42-
// ...
43-
buffer[n] = '\0';
54+
buffer[n] = '\0';
4455
}
4556
```

0 commit comments

Comments
 (0)