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

后端 未结 6 2115
别跟我提以往
别跟我提以往 2021-02-14 00:29

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:16

    The most obvious cause is simply the use of #ifdef and #ifndef directives associated DEBUG or similar symbol that change between the two builds.

    Before going down the debugging road (which is not my personal idea of fun), I would inspect both command lines and check which flags are passed in one mode and not the other, then grep my code for this flags and check their uses.

    One particular issue that comes to mind are macros:

    #ifdef _DEBUG_
      #define CHECK(CheckSymbol) { if (!(CheckSymbol)) throw CheckException(); }
    #else
      #define CHECK(CheckSymbol)
    #endif
    

    also known as a soft-assert.

    Well, if you call it with a function that has side effect, or rely on it to guard a function (contract enforcement) and somehow catches the exception it throws in debug and ignore it... you will see differences in release :)

提交回复
热议问题