Remove useless files, includes, global variables a

2019-04-09 15:59发布

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.

1条回答
在下西门庆
2楼-- · 2019-04-09 16:46

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:

The "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.

查看更多
登录 后发表回答