g++ How to get warning on ignoring function return value

前端 未结 5 1144
伪装坚强ぢ
伪装坚强ぢ 2020-11-30 04:52

lint produces some warning like:

foo.c XXX Warning 534: Ignoring return value of function bar()

From the lint manual

5条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 05:13

    I solved the problem like this:

    #define ignore_result(x) if (x) {}
    

    then instead of (void)foo() use ignore_result(foo())

    Then the code compiles with -Wall just fine.

提交回复
热议问题