I modified a huge C++ project with lots of files and functions. The problem is, that now there are tons of useless files, includes, global variables and functions. Removing them by hand would be a pain. Is there a tool that analyzes the code like a compiler does and deletes all unused stuff? I would prefer a tool for unix. Also a way to remove only one or a few of the useless components named above would help.
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
There several posibilities of the GNU toolchain itself to optimize codesize, if you don't mind that the linker does this every time you build your system. And there is always the question in C++ what really is "unused code" (since working with pointers and casts can mislead any tool).
So your best bet for this is the Gold linker (Replacing ld with gold - any experience?) and the following options:
-gc-sections
: GCC --gc-sections and finding symbol dependencies--icf
: GCC(/Clang): Merging functions with identical instructions (COMDAT folding)-Os
: Process for reducing the size of a executableThe "bigger" approach would be static code analyers/code refactoring tools (How can I know which parts in the code are never used?) and then certain libraries like Boost do come with their own tools to reduce the number of files.