Is assert(false) ignored in release mode?

后端 未结 6 1815
耶瑟儿~
耶瑟儿~ 2020-12-15 04:12

I am using VC++. Is assert(false) ignored in release mode?

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-15 04:54

    The assert macro (at least it is typically a macro) is usually defined to no-op in release code. It will only trigger in debug code. Having said that. I have worked at places which defined their own assert macro, and it triggered in both debug and release mode.

    I was taught to use asserts for condition which can "never" be false, such as the pre-conditions for a function.

提交回复
热议问题