better-cpp-syntax
better-cpp-syntax copied to clipboard
Switch case highlighting issue with C cast style
- [x] This problem exists even with the setting
"C_Cpp.enhancedColorization": "Disabled"
- [x] This bug exists for C
- [ ] This bug exists for C++
- [ ] This bug exists for Objective-C
- [ ] This bug exists for Objective-C++
The code with a problem is:
int my_function()
{
// Stub
return 0;
}
// Main function
int main(int argc, char *argv[])
{
int a;
switch (a)
{
case 0:
(void)my_function();
break;
default:
break;
}
return 0;
}
It looks like:
It should look like:
Adding a space after (void)
fixed the issue.
Hmm I'm unable to reproduce this behavior (it is yellow for me in both cases), do you have the latest version of the extension installed?
Also if you don't mind me asking, what does casting to void do?
Really strange, this behaviour have been found internally in our company. I was able to reproduce the bug, that's why I opened this issue.
Well, I'm only using the C/C++ extension (version 0.26.0) and VSCode (version 1.39.2).
Putting the (void)
means here we make explicit the discarded value returned by the function. It just serves as a marker to inform that the function returns a value, but this value is discarded.
Edit: Hum. Don't have the same behaviour this time. Only the keyword default
is bad highlighted.
It could be the C++ extension so you might try disabling it, although it is strange that it would affect default
It seems the problem is here without the C/C++ extension enabled. Can you confirm it ?
@jeff-hykin afaik enhanced colorization will never remove highlighting, it can cause bad highlighting, but none of the scopes it maps to should be colored the same as text.
Ah I found the problem. This doesn't produce for me in C++, however it does in C.