I am migrating code from C to C ++ and found this code:
if(ErrorCode >= SOME_CONSTANT)
{
Status = RETVAL_OK;
switch ( ErrorCode )
{
default:
Status = RETVAL_FAILED;
break;
}
}
This code generates a compilation warning:
warning C4065: switch statement contains 'default' but no 'case' labels
Question: is there any purpose of the switch statement (which I did not understand) or is it just cool code?
That is, is there any reason (when compiling for ANSI C or C ++) not to write it like this?
if(ErrorCode >= SOME_CONSTANT)
Status = RETVAL_FAILED;
EDIT . To answer all your questions:
The code is not intended to be extended: it was the last release of the module, which was delivered four years ago (since then it has not been affected, so I am inclined to believe that it is cool).
case ( ( switch/default a, ). , , .
.