How to put assert into release builds in C/C++

前端 未结 7 1093
野性不改
野性不改 2020-12-24 02:18

I need to only run ship build and I need to assert on certain condition in release build to see if the problem is fixed. How do I do it?

7条回答
  •  半阙折子戏
    2020-12-24 03:13

    Undefine the NDEBUG macro - you can do this locally around the asserts you want to remain in the build:

    #undef NDEBUG
    #include    // reinclude the header to update the definition of assert()
    

    or do whatever you need to do so your build process does not define the NDEBUG macro in the first place.

提交回复
热议问题