Do unused functions get optimized out?(未使用的功能会得到优化吗?)
问题描述
一个相当简单的问题...如今的编译器倾向于进行大量优化.他们是否还会从最终输出中删除未使用的功能?
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.
这篇关于未使用的功能会得到优化吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:未使用的功能会得到优化吗?
基础教程推荐
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- CString 到 char* 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
