<i id='17ZN8'><tr id='17ZN8'><dt id='17ZN8'><q id='17ZN8'><span id='17ZN8'><b id='17ZN8'><form id='17ZN8'><ins id='17ZN8'></ins><ul id='17ZN8'></ul><sub id='17ZN8'></sub></form><legend id='17ZN8'></legend><bdo id='17ZN8'><pre id='17ZN8'><center id='17ZN8'></center></pre></bdo></b><th id='17ZN8'></th></span></q></dt></tr></i><div id='17ZN8'><tfoot id='17ZN8'></tfoot><dl id='17ZN8'><fieldset id='17ZN8'></fieldset></dl></div>
      <bdo id='17ZN8'></bdo><ul id='17ZN8'></ul>
    <tfoot id='17ZN8'></tfoot>

      <legend id='17ZN8'><style id='17ZN8'><dir id='17ZN8'><q id='17ZN8'></q></dir></style></legend>
    1. <small id='17ZN8'></small><noframes id='17ZN8'>

      我应该如何检测大型 C++ 项目中不必要的 #include 文件?

      How should I detect unnecessary #include files in a large C++ project?(我应该如何检测大型 C++ 项目中不必要的 #include 文件?)

      <small id='1uwm6'></small><noframes id='1uwm6'>

        <tbody id='1uwm6'></tbody>

      <legend id='1uwm6'><style id='1uwm6'><dir id='1uwm6'><q id='1uwm6'></q></dir></style></legend>

      <tfoot id='1uwm6'></tfoot>
        • <bdo id='1uwm6'></bdo><ul id='1uwm6'></ul>
        • <i id='1uwm6'><tr id='1uwm6'><dt id='1uwm6'><q id='1uwm6'><span id='1uwm6'><b id='1uwm6'><form id='1uwm6'><ins id='1uwm6'></ins><ul id='1uwm6'></ul><sub id='1uwm6'></sub></form><legend id='1uwm6'></legend><bdo id='1uwm6'><pre id='1uwm6'><center id='1uwm6'></center></pre></bdo></b><th id='1uwm6'></th></span></q></dt></tr></i><div id='1uwm6'><tfoot id='1uwm6'></tfoot><dl id='1uwm6'><fieldset id='1uwm6'></fieldset></dl></div>
                本文介绍了我应该如何检测大型 C++ 项目中不必要的 #include 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在 Visual Studio 2008 中处理一个大型 C++ 项目,并且有很多文件带有不必要的 #include 指令.有时 #include 只是工件,删除它们后一切都会很好地编译,而在其他情况下,可以向前声明类,并且可以将 #include 移动到 .cpp 文件.有没有什么好的工具可以检测这两种情况?

                I am working on a large C++ project in Visual Studio 2008, and there are a lot of files with unnecessary #include directives. Sometimes the #includes are just artifacts and everything will compile fine with them removed, and in other cases classes could be forward declared and the #include could be moved to the .cpp file. Are there any good tools for detecting both of these cases?

                推荐答案

                虽然它不会显示不需要的包含文件,但 Visual Studio 有一个设置 /showIncludes(右键单击 .cpp 文件,Properties->C/C++->Advanced) 将在编译时输出所有包含文件的树.这有助于识别不需要包含的文件.

                While it won't reveal unneeded include files, Visual studio has a setting /showIncludes (right click on a .cpp file, Properties->C/C++->Advanced) that will output a tree of all included files at compile time. This can help in identifying files that shouldn't need to be included.

                您还可以查看 pimpl idiom,以减少头文件依赖项,从而更轻松地查看可以删除的内容.

                You can also take a look at the pimpl idiom to let you get away with fewer header file dependencies to make it easier to see the cruft that you can remove.

                这篇关于我应该如何检测大型 C++ 项目中不必要的 #include 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                C++ stl unordered_map implementation, reference validity(C++ stl unordered_map 实现,参考有效性)
                C++: Is it possible to use a reference as the value in a map?(C++:是否可以使用引用作为映射中的值?)
                Where ampersand quot;amp;quot; can be put when passing argument by reference?(其中符号“amp;通过引用传递参数时可以放置吗?)
                Why can a non-const reference parameter be bound to a temporary object?(为什么可以将非常量引用参数绑定到临时对象?)
                What is a dangling reference?(什么是悬空引用?)
                C++ reference changes when push_back new element to std::vector(当 push_back 新元素到 std::vector 时,C++ 引用发生变化)

                  <small id='73jTO'></small><noframes id='73jTO'>

                  <tfoot id='73jTO'></tfoot>
                  • <bdo id='73jTO'></bdo><ul id='73jTO'></ul>

                    <i id='73jTO'><tr id='73jTO'><dt id='73jTO'><q id='73jTO'><span id='73jTO'><b id='73jTO'><form id='73jTO'><ins id='73jTO'></ins><ul id='73jTO'></ul><sub id='73jTO'></sub></form><legend id='73jTO'></legend><bdo id='73jTO'><pre id='73jTO'><center id='73jTO'></center></pre></bdo></b><th id='73jTO'></th></span></q></dt></tr></i><div id='73jTO'><tfoot id='73jTO'></tfoot><dl id='73jTO'><fieldset id='73jTO'></fieldset></dl></div>
                    • <legend id='73jTO'><style id='73jTO'><dir id='73jTO'><q id='73jTO'></q></dir></style></legend>
                          <tbody id='73jTO'></tbody>