How can I tell gcc to warn (or fail) on switch/case statements without a break?

后端 未结 6 1340
有刺的猬
有刺的猬 2021-01-17 17:50

I have a complicated switch statement, and I forgot to put a break at the end of one of the cases. This is quite legal, and as a resu

6条回答
  •  逝去的感伤
    2021-01-17 17:56

    I just went through gcc options, and there is none that will at least give you a notice. There are -Wswitch, -Wswitch-default and -Wswitch-enum ( http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#Warning-Options ), but none of them will work for you.

    my best bet would be to use 'else if' statements

提交回复
热议问题