2 ms·
Would be nice if compilers offered a warning for missing breaks in a switch statement, and a pragma to mark fallthrough: switch(something) { ca
by kstenerud 14y ago
Would be nice if compilers offered a warning for missing breaks in a switch statement, and a pragma to mark fallthrough:
switch(something)
{
case 1:
// Do stuff
break;
case 2:
#pragma switch_fallthrough
case 3:
// Do stuff
break;
#pragma switch_nodefault
}
- there 14y agolint will warn about those cases unless they are marked in the code with /* FALLTHROUGH */. I think even if you're not using lint, such comments are good practice.