I'm trying to use the c++17 [[fallthrough]]
attribute in visual studio 2017:
Qt::ItemFlags flags = Qt::ItemIsSelectable;
switch (index.column())
{
case 0:
flags |= Qt::ItemIsUserCheckable;
break;
case 2:
[[fallthrough]]
case 3:
[[fallthrough]]
case 4:
flags |= Qt::ItemIsEditable;
break;
}
return flags;
but I get the compiler error:
attribute 'fallthrough' cannot be applied in this context
This seems like the only context where you can use [[fallthrough]]
... what am I doing wrong?
This cryptic error is given because [[fallthrough]]
attributes require a semicolon to terminate them. Rewriting the case statement as
case 2:
[[fallthrough]];
case 3:
[[fallthrough]];
// ...
resolves the error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With