19

C++ syntax highlighting does not work when , , or are used, unless is added as well. However, it does work with alone so I know it is possible, and makes me think the former was not intended behaviour. I'd like to see this extended to all the variants.

6
  • 8
    I know how to fix this easily. Why not just use the c++ tag?
    – Braiam
    Commented Feb 20, 2019 at 17:19
  • 1
    @Braiam Well, that's what I propose above (and do), too, but often when a tag like c++20 is relevant it's really a question about that specific dialect, not applicable to C++ in general.
    – The Vee
    Commented Feb 20, 2019 at 17:21
  • 14
    @TheVee: But the question needs the attention of C++ experts, since it's a question about C++. So it should have the C++ tag. Commented Feb 20, 2019 at 17:31
  • 6
    If you use triple tick marks to demarcate your code, you could follow the first set of triple ticks by a space and then lang-cpp. This will force C++ highlighting for the code block.
    – rsjaffe
    Commented Feb 20, 2019 at 21:07
  • 6
    <!-- language: lang-cpp --> while using 4 space formattings Commented Feb 21, 2019 at 11:37
  • Related: A proposal for tag hierarchy on Stack Exchange sites Commented Feb 22, 2019 at 5:06

2 Answers 2

26

Braiam is right: the solution here is to tag all questions with the tag, and then you'll automatically get syntax highlighting appropriate for the C++ tag.

This is just another special case of the more general rule that, when you use a version-specific tag, you should also always tag with the "main" tag.

For example, when you tag with , you also tag with . When you tag with , you also tag with . When you tag with , you also tag with . Et cetera.

Nicol Bolas already gives the real reason for this:

[T]he question needs the attention of C++ experts, since it's a question about C++. So it should have the C++ tag.

The tag system is designed to help experts find questions. It is a classificatory system. A large number of our expert answerers filter based on tag, and they don't always include version-specific tags in their filters, so they may easily miss your question if you don't use the primary tag.

We (moderators) could add syntax highlighting hints to the version-specific tags, but it is not necessary because of the ground rules for version-specific tags. Think of the lack of syntax highlighting as an incentive to tag the question correctly.

6
  • 5
    Oh, I did not know that was a rule. Actually I believed the opposite was what was expected. Good to know (and have in writing) and sorry!
    – The Vee
    Commented Feb 20, 2019 at 18:30
  • 4
    No need to apologize. Apparently this guideline is not nearly as well-known as I thought.
    – Cody Gray Mod
    Commented Feb 20, 2019 at 18:31
  • 1
    Often enough I find a question running out of tag space and have to decide which of a worthy one needs to go to make room for another slightly better one. This compounds that, unfortunately. Commented Feb 22, 2019 at 1:10
  • 1
    I think that's only ever happened to me a handful of times in ~9 years, @Dave. A lot of people overuse tags. They're supposed to describe the content of the question itself, not just the context or the broader ecosystem. If your question isn't about the IDE itself, you don't tag with [visual-studio], for example. If it's not about features of the Windows OS, you don't tag with [windows]. That narrows the list down pretty quickly.
    – Cody Gray Mod
    Commented Feb 22, 2019 at 1:47
  • 1
    Including a supertag when subtagging also means that 5 tags might not be enough Commented Feb 22, 2019 at 4:20
  • @CodyGray I notice it on questions which crossover the usual 'boundaries'. I look at a lot of VB6 / COM interop / C# questions which tend to need more tags than normal. Also, it is obviously hard to know which specific tags have the most "experts" following them though some might be obvious. Personally I follow the esoteric as well as broader tags because of that. Assuming people will tag well seems like a bad guess. Commented Feb 22, 2019 at 12:29
1

The tag usage is supposedly: use always, then add specific standard tags if needed. People watch the main C++ tag but not necessarily the rest of them. So by just using , the C++11 experts might not even read your post.

I would think this to be more important to the person asking the question than code formatting.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .