visual-studio Visual Studio 中的发布和调试模式有什么区别?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/933739/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 10:34:56  来源:igfitidea点击:

What is the difference between Release and Debug modes in Visual Studio?

visual-studiovisual-studio-2005conditional-compilation

提问by Cute

Possible Duplicate:
Debug vs. release in .NET
Debug/Release difference

可能的重复:
.NET调试/发布差异中的调试与发布

What is the difference between Release and Debug modes in Visual Studio while building a project?

构建项目时,Visual Studio 中的发布和调试模式有什么区别?

采纳答案by Tal Pressman

Well, it depends on what language you are using, but in general they are 2 separate configurations, each with its own settings. By default, Debug includes debug information in the compiled files (allowing easy debugging) while Release usually has optimizations enabled.

嗯,这取决于您使用的语言,但通常它们是 2 个独立的配置,每个配置都有自己的设置。默认情况下,Debug 在编译文件中包含调试信息(允许轻松调试),而 Release 通常启用优化。

As far as conditional compilation goes, they each define different symbols that can be checked in your program, but they are language-specific macros.

就条件编译而言,它们各自定义了可以在您的程序中检查的不同符号,但它们是特定于语言的宏。

回答by Roger Lipscombe

Debugand Releaseare just labels for different solution configurations. You can add others if you want. A project I once worked on had one called "Debug Internal" which was used to turn on the in-house editing features of the application. You can see this if you go to Configuration Manager...(it's on the Buildmenu). You can find more information on MSDN Library under Configuration Manager Dialog Box.

DebugRelease只是不同解决方案配置的标签。如果需要,您可以添加其他人。我曾经参与过的一个项目名为“Debug Internal”,用于打开应用程序的内部编辑功能。如果你去Configuration Manager...(它在Build菜单上),你可以看到这个。您可以在Configuration Manager Dialog Box下找到有关 MSDN Library 的更多信息。

Each solution configurationthen consists of a bunch of project configurations. Again, these are just labels, this time for a collection of settings for your project. For example, our C++ library projects have project configurations called "Debug", "Debug_Unicode", "Debug_MT", etc.

每个解决方案配置然后由一堆项目配置组成。同样,这些只是标签,这次是为您的项目设置的集合。例如,我们的 C++ 库项目有名为“Debug”、“Debug_Unicode”、“Debug_MT”等的项目配置。

The available settings depend on what type of project you're building. For a .NET project, it's a fairly small set: #defines and a few other things. For a C++ project, you get a much bigger variety of things to tweak.

可用设置取决于您正在构建的项目类型。对于 .NET 项目,它是一个相当小的集合:#defines 和其他一些东西。对于 C++ 项目,您可以进行更多种类的调整。

In general, though, you'll use "Debug" when you want your project to be built with the optimiser turned off, and when you want full debugging/symbol information included in your build (in the .PDB file, usually). You'll use "Release" when you want the optimiser turned on, and when you don'twant full debugging information included.

但是,一般而言,当您希望在关闭优化器的情况下构建项目时,以及希望在构建中包含完整的调试/符号信息(通常在 .PDB 文件中)时,您将使用“调试”。当您想要打开优化器以及希望包含完整的调试信息时,您将使用“Release” 。

回答by Tetraneutron

The main difference is when compiled in debug mode, pdb files are also created which allow debugging (so you can step through the code when its running). This however means that the code isn't optimized as much.

主要区别在于在调试模式下编译时,还会创建允许调试的 pdb 文件(因此您可以在代码运行时单步执行)。然而,这意味着代码没有优化太多。