last
should not be highlighted as it is not a keyword in C++. Not sure why the gcc tag causes it to be highlighted as that's a compiler, not a language.
Steps to reproduce:
- Edit
- Remove the gcc tag
- Make a minor edit in the textbox to force refresh
last
should not be highlighted as it is not a keyword in C++. Not sure why the gcc tag causes it to be highlighted as that's a compiler, not a language.
Steps to reproduce:
I don't think that is a bug. From What is syntax highlighting and how does it work?
If there's more than one tag that has syntax highlighting, it uses a default and lets Prettify infer what's the best language to use.
That question has multiple tags with a language hint on it (scroll to the end of the wiki):
for-loop has no language hint.
This means Prettify falls back to the Default which is all possible keywords of major languages smashed together. I explained more in depth how that works here.
If you want proper highlighting add the explicit prettifier to use <!-- language: lang-cpp -->
or <!-- language: lang-c -->
above the relevant code blocks.
Or even better: Don't mix C and C++, ever.
cpp
.
Commented
Jul 27, 2016 at 16:00
lang-c
. g++ should use lang-cpp
. Obviously there's nothing wrong with tagging a C++ question with gcc, though, so this just proves that syntax highlighting is hard. Perhaps the best thing to do would be to remove the syntax highlighting hint from gcc and g++ since those would never be correctly used without either c or c++.