[MSDN] How to Debug a Release Build

本文介绍如何在Visual C++中调试发布版本的C/C++程序。通过调整编译选项,如启用/Z7或/Zi,禁用增量链接等,可以在发布模式下进行调试。当程序在调试版本下正常运行,而在发布版本下失败时,可以通过逐步禁用优化来定位问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 
Visual C++ Concepts: Building a C/C++ Program
How to: Debug a Release Build
You can debug a release build.
To enable debugging of a release build, change the following release build options
1. Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.
2. Enable /Z7 or /Zi.
3. Select/INCREMENTAL:NO.
4. Select /DEBUG:Yes.
5. Select /OPT:REF.
6. Select /OPT:ICF.
You can now debug your release build application. To find the problem, step through the code (or of using Just-In-Time debugging) until you find where the failure occurs, and then determine the incorrect parameters or code.
If a program works in a debug build, but fails in a release build, it is likely that one of the compiler optimizations is exposing a defect in your source code. To isolate the problem, you should disable selected optimizations for each source code file, until you locate the file and the optimization that is causing the problem. For example, you may want to divide the files into two groups, disable optimization on one group, and continue dividing until you isolate the problem to a single file.
You may want to use /RTC to try to expose such bugs in your debug builds.
See Optimizing Your Code for more information.
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值