简体   繁体   English

为什么Visual C ++编译器将未使用的类编译为可执行文件?

[英]Why Visual C++ compiler compiles unused classes into executable?

我可能会误解编译器的工作方式,但是我遇到以下情况。我有一个VC ++ 2012项目。该项目包含具有数百个类的API。现在,我创建了“ main”入口点文件,其中仅使用了一些std的东西。主要的甚至不包含来自API的单个标头,但是当我编译时,我看到API的几乎所有内容都被编译为可执行文件了,为什么会发生,这是我应该在项目属性中配置的东西吗?

Source files that are part of the project are compiled also if "unused" through headers and references from your main routine. 如果通过主程序标头和引用“未使用”,则也将编译属于项目的源文件。

If you don't want those compiled simply remove them from the project. 如果您不希望编译这些内容,只需将它们从项目中删除即可。 The compiler might be able to optimize everything away but that doesn't mean they're not compiled if part of the project first. 编译器也许可以优化所有内容,但这并不意味着如果项目的一部分首先不对它们进行编译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM