Emulating GCC's __builtin_unreachable?

前端 未结 5 1853
春和景丽
春和景丽 2020-12-24 13:18

I get a whole lot of warnings about switches that only partially covers the range of an enumeration switched over. Therefor, I would like to have a \"default\" for

5条回答
  •  粉色の甜心
    2020-12-24 13:41

    keep it simple:

    assert(false);
    

    or, better yet:

    #define UNREACHABLE (!"Unreachable code executed!")
    
    assert(UNREACHABLE);
    

提交回复
热议问题