未使用的功能会得到优化吗? [英] Do unused functions get optimized out?

查看:30
本文介绍了未使用的功能会得到优化吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个相当简单的问题...如今的编译器倾向于进行大量优化.他们是否还会从最终输出中删除未使用的功能?

A fairly simple question... Compilers these days tend to do a significant amount of optimizations. Do they also remove unused functions from the final output?

推荐答案

这取决于编译器.Visual C++ 9 可以做到这一点 - 未使用的 static 函数在编译阶段被删除(甚至还有一个 C4505 警告),可以在链接阶段删除未使用的具有外部链接的函数 取决于链接器设置.

It depends on the compiler. Visual C++ 9 can do that - unused static functions are removed at compilation phase (there's even a C4505 warning for that), unused functions with external linkage can be removed at link phase depending on linker settings.

这篇关于未使用的功能会得到优化吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆