You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/ide/include-cleanup-messages.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ Starting with 17.8 Preview 1, Visual Studio can clean up your `#include`s to imp
15
15
- Offers to add header files for code that is only working because the needed header file is included indirectly.
16
16
- Offers to remove unused header files--improving build times.
17
17
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).
19
19
20
20
In the following screenshot of the Error List, include cleanup is configured to show unused headers with a warning:
21
21
@@ -29,11 +29,11 @@ Include cleanup generates the following messages:
29
29
30
30
This message means that you're using content from a header file that is included indirectly.
31
31
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).
33
33
34
34
## `VCIC002`: #include is not used in this file
35
35
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.
Copy file name to clipboardExpand all lines: docs/ide/include-cleanup-overview.md
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ Include cleanup helps you find and fix issues like this. It analyzes your code a
62
62
63
63
## Unused headers
64
64
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`:
66
66
67
67
```cpp
68
68
// myProgram.cpp
@@ -111,15 +111,15 @@ The tool doesn't update the comments, but you can see that the code is now using
111
111
112
112
## Best practice
113
113
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.
115
115
116
116
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:
117
117
118
118
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."
120
120
1. Hover your cursor over line with the suggestion and invoke the quick action menu by clicking the broom or pressing Ctrl+period.
121
121
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."
123
123
1. Hover your cursor over the unused header and choose **Remove #include \<header\>**.
124
124
1. Repeat these steps until there are no more suggestions about transitive includes or unused includes.
125
125
1. Repeat these steps for the other files in your project that you wish to clean up.
0 commit comments