Skip to content

Commit bfb2d75

Browse files
TylerMSFTTylerMSFT
authored andcommitted
acrolinx
1 parent 74587c4 commit bfb2d75

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

docs/ide/include-cleanup-messages.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Starting with 17.8 Preview 1, Visual Studio can clean up your `#include`s to imp
1515
- Offers to add header files for code that is only working because the needed header file is included indirectly.
1616
- Offers to remove unused header files--improving build times.
1717

18-
You can choose whether messages from Include cleanup appear in the form of suggestions, warnings, or errors in the Error List window. The form is determined by settings in Visual Studio tools options. For more information, see [Config C/C++ include cleanup in Visual Studio](include-cleanup-config.md).
18+
You can choose whether messages from Include cleanup appear in the form of suggestions, warnings, or errors in the Error List window. For more information, see [Config C/C++ include cleanup in Visual Studio](include-cleanup-config.md).
1919

2020
In the following screenshot of the Error List, include cleanup is configured to show unused headers with a warning:
2121

@@ -29,11 +29,11 @@ Include cleanup generates the following messages:
2929

3030
This message means that you're using content from a header file that is included indirectly.
3131

32-
For example, you may be directly including a header file that also contains `#include <string>`. If you use `string` in your code, but don't `#include <string>` in that file, it works as long as the other header file continues to indirectly include `<string>` for you. This message identifies this sitution in your code so that you can take action to directly include the transitively included header file. For more information, see [Direct vs indirect headers](include-cleanup-overview.md#direct-vs-indirect-headers).
32+
For example, you may be directly including a header file that also contains `#include <string>`. If you use `string` in your code, but don't `#include <string>` in that file, it works as long as the other header file continues to indirectly include `<string>` for you. This message identifies this situation in your code so that you can take action to directly include the transitively included header file. For more information, see [Direct vs indirect headers](include-cleanup-overview.md#direct-vs-indirect-headers).
3333

3434
## `VCIC002`: #include is not used in this file
3535

36-
This message means that the specified header file is not used in the current file. You can remove the associated `#include` directive to cleanup your includes and improve your build times.
36+
This message means that the specified header file is not used in the current file. You can remove the associated `#include` directive to clean up your `#include`s and improve your build times.
3737

3838
## See also
3939

docs/ide/include-cleanup-overview.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Include cleanup helps you find and fix issues like this. It analyzes your code a
6262

6363
## Unused headers
6464

65-
As your code evolves, you may no longer need some header files. This is hard to keep track of in a complex project. Over time, your build time may be slowed by the compiler processing unnecessary header files. Include cleanup helps you find and remove unused headers. For example, what if `myFunc()` is commented out in `myProgram.cpp`:
65+
As your code evolves, you may no longer need some header files. This is hard to keep track of in a complex project. Over time, your builds may take longer because the compiler is processing unnecessary header files. Include cleanup helps you find and remove unused headers. For example, what if `myFunc()` is commented out in `myProgram.cpp`:
6666

6767
```cpp
6868
// myProgram.cpp
@@ -111,15 +111,15 @@ The tool doesn't update the comments, but you can see that the code is now using
111111

112112
## Best practice
113113

114-
Don't remove what appear to be unused header files without first adding indirectly included header files. That's because you may be relying on indirect includes that you (and the tool) aren't aware of in a header file that is otherwise unused. The tool can't tell if you're relying on indirect includes, so add transitively used headers first. Then when you remove unused headers, you won't have code that doesn't compile due to a missing header that was included indirectly by a header file you've removed.
114+
Don't remove what appear to be unused header files without first adding indirectly included header files. That's because you may be relying on indirect includes that you (and the tool) aren't aware of in a header file that is otherwise unused. The tool can't tell if you're relying on indirect includes, so add transitively used headers first. Then when you remove unused headers, you won't have compilation errors due to a missing header file that was included indirectly by a header file you've removed.
115115

116116
To do this, set the include cleanup setting for **Add missing includes suggestion level** to **Suggestion** (**Tools** > **Options** > **Text Editor** > **C/C++** > **Code Cleanup**). Also set **Remove unused includes suggestion level** to **Suggestion**. Then:
117117

118118
1. In the error list, make sure the filter is set to **Build + IntelliSense**.
119-
1. Look for instances of "Content from #include x is used in this file and transitively included".
119+
1. Look for instances of "Content from #include x is used in this file and transitively included."
120120
1. Hover your cursor over line with the suggestion and invoke the quick action menu by clicking the broom or pressing Ctrl+period.
121121
1. Choose **Add all transitively used includes**.
122-
1. Remove unused includes: in the error list, look for all instances of `#include x is not used in this file'.
122+
1. Remove unused includes: in the error list, look for all instances of "#include x is not used in this file."
123123
1. Hover your cursor over the unused header and choose **Remove #include \<header\>**.
124124
1. Repeat these steps until there are no more suggestions about transitive includes or unused includes.
125125
1. Repeat these steps for the other files in your project that you wish to clean up.

0 commit comments

Comments
 (0)