“-Weverything” yielding “Comparing floating point with == or != is unsafe”

后端 未结 5 1916
无人及你
无人及你 2020-12-10 00:58

I have a string that I convert to a double like this:

double d = [string doubleValue];

The documentation for doubleValue tells

5条回答
  •  自闭症患者
    2020-12-10 01:23

    If you are sure about your comparison and you want tell it to clang, surround your code with:

    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wfloat-equal"
    /* My code triggering the warnings */
    #pragma clang diagnostic pop
    

提交回复
热议问题