Discovering Unnecessary #include Files in Vast C Projects
Within a sprawling C project in Visual Studio 2008, countless files contain superfluous #include directives. Occasionally, these #includes are merely relics, allowing compilation post-removal. In other instances, classes can be declared in advance, permitting the #include to be relocated to the .cpp file. Are there tools capable of uncovering both scenarios?
Visual Studio's Inclusion Visualization
Visual Studio offers an /showIncludes setting (accessible via right-clicking on a .cpp file and selecting Properties->C/C ->Advanced) that yields a tree-like representation of all files incorporated during compilation. While this facility fails to flag unneeded inclusion files, it can highlight files that are likely redundant.
Pimpl Idiom for Reduced Code Interdependence
The pimpl idiom presents an additional option, minimizing header file interdependencies. This technique facilitates easier detection of removable cruft by isolating implementation code from header files.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3