How to write a c++ assert macro with a varying number of informational arguments?

后端 未结 5 1510
情深已故
情深已故 2021-01-14 15:09

I am trying to write a macro dbgassert similar to the standard assert. In addition to what assert does, I want to dbgassert

5条回答
  •  被撕碎了的回忆
    2021-01-14 15:36

    You're assuming that assert is implemented by calling __assert. This may well be how one particular implementation works, but certainly cannot be depended on in general.

    Instead, follow the documentation: test your condition and on failure emit diagnostic information to standard error, then call std::abort.

提交回复
热议问题