Best practices and tools for debugging differences between Debug and Release builds?

后端 未结 6 1800
失恋的感觉
失恋的感觉 2021-02-14 00:40

I\'ve seen posts talk about what might cause differences between Debug and Release builds, but I don\'t think anybody has addressed from a development standpoint what is

6条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-14 01:24

    The very existence of two configurations is a problem from debugging point of view. Proper engineering would be such that the system on the ground and in the air behave the same way, and achieve this by reducing the number of ways by which the system can tell the difference.

    Debug and Release builds differ in 3 aspects:

    • _DEBUG define
    • optimizations
    • different version of the standard library

    The best way around, the way I often work, is this:

    • Disable optimizations where performance is not critical. Debugging is more important. Most important is disable function auto-inlining, keep standard stack frame and variable reuse optimizations. These annoy debug the most.
    • Monitor code for dependence on DEBUG define. Never use debug-only asserts, or any other tools sensitive to DEBUG define.
    • By default, compile and work /release.

提交回复
热议问题