CUDA: NVCC gives controlling expression is constant warning on assert

前端 未结 5 1949
小鲜肉
小鲜肉 2021-01-18 14:09

I get the warning controlling expression is constant on assert statement like this:

assert(... && \"error message\");

5条回答
  •  灰色年华
    2021-01-18 15:02

    Add the following somewhere near the beginning of your code:

    #pragma diag_suppress boolean_controlling_expr_is_constant
    

    Note that this will suppress all compiler warnings for "controlling expression is constant", not just the warning associated with your assertions.

    I sometimes get this warning when checking constants or properties that are defined (or can be derived) at compile time, so in my experience the warning has been generally benign and OK to ignore.

提交回复
热议问题