当前位置:网站首页>debug和release的区别
debug和release的区别
2022-07-04 22:37:00 【编程小段】
我们在使用Visual Studio编译cpp代码时,会有debug和release两种模式,那么这两种模式有什么区别呢?
先说结论:
一般在开发过程中,我们往往写的代码会有bug,为了便于调试,会选择debug模式进行编译,目的是不让编译器进行编译优化或者优化的少一些;但在开发完需要发布版本的时候,为了使生成的机器代码更快的运行,往往会选择release模式,这样编译器就会尽可能的帮我们进行编译优化。
下面来解释为什么
例如,我们写了一段代码,计算从0加到999的值,如果不使用编译器优化,那么生成的汇编代码如右半部分所示。
int main()
{
int res;
for(int i=0; i<1000; i++)
{
res += i;
}
return res;
}

但是,如果使用了-O3级别的编译器优化(数字越大,优化级别越高),那么生成的汇编代码就变成了如下所示。因为编译器分析发现这段代码就是返回499500这个值,所以会优化成这样的汇编代码,显然运行速度快很多。但是假如我们需要在for循环内进行debug调试时,编译器会找不到这样的代码,因为汇编代码就没有for循环,所以不会调试。但是没有进行优化的代码就可以在for循环内部进行调试。

边栏推荐
- LabVIEW中比较两个VI
- EditPlus--用法--快捷键/配置/背景色/字体大小
- P2181 diagonal and p1030 [noip2001 popularization group] arrange in order
- 常用技术指标之一文读懂BOLL布林线指标
- String类中的常用方法
- Redis démarrer le tutoriel complet: Pipeline
- Redis introduction complete tutorial: detailed explanation of ordered collection
- 9 - class
- Photoshop批量给不同的图片添加不同的编号
- On-off and on-off of quality system construction
猜你喜欢

MYSQL架构——逻辑架构

Redis getting started complete tutorial: hash description

攻防世界 MISC 高手进阶区 001 normal_png

Redis入門完整教程:Pipeline

A complete tutorial for getting started with redis: hyperloglog

One of the commonly used technical indicators, reading boll Bollinger line indicators

Install the gold warehouse database of NPC

Talk about Middleware

Editplus-- usage -- shortcut key / configuration / background color / font size

Google Earth engine (GEE) - tasks upgrade enables run all to download all images in task types with one click
随机推荐
Redis getting started complete tutorial: publish and subscribe
Redis入门完整教程:Redis使用场景
图片懒加载的原理
Sword finger offer 68 - ii The nearest common ancestor of binary tree
Common methods in string class
Redis: redis configuration file related configuration and redis persistence
智力考验看成语猜古诗句微信小程序源码
Async await used in map
Tweenmax emoticon button JS special effect
colResizable. JS auto adjust table width plug-in
剑指 Offer 67. 把字符串转换成整数
Sword finger offer 68 - I. nearest common ancestor of binary search tree
The new version judges the code of PC and mobile terminal, the mobile terminal jumps to the mobile terminal, and the PC jumps to the latest valid code of PC terminal
为什么信息图会帮助你的SEO
A complete tutorial for getting started with redis: hyperloglog
企业如何跨越数字化鸿沟?尽在云原生2.0
该如何去选择证券公司,手机上开户安不安全
Redis入门完整教程:哈希说明
Is Huatai Securities a nationally recognized securities firm? Is it safe to open an account?
UML diagram memory skills