What is the best way of implementing assertion checking in C++?

后端 未结 11 1239
被撕碎了的回忆
被撕碎了的回忆 2020-12-24 07:31

By that I mean, what do I need to do to have useful assertions in my code?

MFC is quite easy, i just use ASSERT(something).

What\'s the non-MFC way?

11条回答
  •  南笙
    南笙 (楼主)
    2020-12-24 08:30

    use intellisense to open it in visual studio (right click)

    // cassert standard header
    #include 
    #include 
    

    yvals.h is windows stuff. so, as far as assert() itself is concerned, the two ways to include it are identical. it's good practice to use the because often it isn't that simple (namespace wrapping and maybe other magic)

    This breaks at caller site for me...

    here's an article explaining why you don't want to write this macro yourself.

提交回复
热议问题