MSVC equivalent of __attribute__ ((warn_unused_result))?

前端 未结 5 2155
旧时难觅i
旧时难觅i 2020-12-05 23:41

I\'m finding __attribute__ ((warn_unused_result)) to be very useful as a means of encouraging developers not to ignore error codes returned by functions, but I

5条回答
  •  無奈伤痛
    2020-12-06 00:22

    It's _Check_return_. See here for examples of similar annotations and here for function behaviour. It's supported since MSVC 2012.

    Example:

    _Check_return_
    int my_return_must_be_checked() {
        return 42;
    }
    

提交回复
热议问题