5 ms·
If had a similar issue (in C) that took me at least an hour to find: switch (whatever) { E_START: // code break; E_PAUSE: // c
by _pmf_ 9y ago
If had a similar issue (in C) that took me at least an hour to find:
switch (whatever)
{
E_START:
// code
break;
E_PAUSE:
// code
break;
E_END:
// code
break;
}
i.e. accidentally using labels instead of "case E_START:". GCC at least had the decency of generating a warning about unused labels, while I suppose `javac` does no such thing.
- astura 9y agoJust tested in my Eclipse project This mistake (unsurprisingly) isn't possible in Java: "Syntax error on token "{", case expected after this token" With an unused label I get the warning "The label E_START is never explicitly referenced" A good software process prevents these types of errors. You shouldn't have any warning in your project at all, and if you see one you'll know to check it out. You should use @SuppressWarnings for any warnings you have reviewed and have determined are not errors. Your IDE should mark warnings clearly at the project level, the file, and the offending line. They also should have an overall list of warnings (and errors) and you should go through them before building a release.
- kwhitefoot 9y agoI rather like the JPL rules which say that code MUST compile with NO warnings even if the warning is wrong. See rule 2 in https://lars-lab.jpl.nasa.gov/JPL_Coding_Standard_C.pdf https://lars-lab.jpl.nasa.gov/JPL_Coding_Standard_C.pdf.