assert() with message

前端 未结 7 681
醉梦人生
醉梦人生 2020-12-24 01:08

I saw somewhere assert used with a message in the following way:

assert((\"message\", condition));

This seems to work great, except that gc

相关标签:
7条回答
  • 2020-12-24 01:53

    By tradition, (void) communicates to the compiler that you are knowingly ignoring an expression:

    /* picard.c, TNG S6E11. */
    #define assertmsg(x, msg) assert(((void) msg, x))
    assertmsg(2+2==5, "There! are! four! lights!");
    
    0 讨论(0)
提交回复
热议问题