I'm building a project which needs to get built with VC2005 for various reasons. One of the files has a switch statement looking like this:-
Code:
---------
switch (argc) {
case 9:
if (types[8] == 'f') {
linkid = (int) argv[8]->f;
} else {
linkid = argv[8]->i;
}
case 8:
if (types[7] == 'f') {
linkset = (int) argv[7]->f;
} else {
linkset = argv[7]->i;
}
case 7:
if (types[6] == 'f') {
port = (int) argv[6]->f;
} else {
port = argv[6]->i;
}
// etc
}
---------
Notice that there are no *break;* statements in between each case. Someone else builds the same project with gcc and he's added some *[[fallthrough]]* lines at the end of each case - i.e.
Code:
---------
switch (argc) {
case 9:
if (types[8] == 'f') {
linkid = (int) argv[8]->f;
} else {
linkid = argv[8]->i;
}
[[fallthrough]];
case 8:
if (types[7] == 'f') {
linkset = (int) argv[7]->f;
} else {
linkset = argv[7]->i;
}
[[fallthrough]];
case 7:
if (types[6] == 'f') {
port = (int) argv[6]->f;
} else {
port = argv[6]->i;
}
[[fallthrough]];
// etc
}
---------
I don't know if later versions of MSVC would accept this but VC2005 doesn't (giving me:- *error C3409: empty attribute block is not allowed*).
Obviously I could just comment out the lines but I just wondered if *fallthrough* is a valid keyword of some kind later versions of C++ ?
↧