38

Background

We've had a lot of meta discussions about the use of and in the same post. Most recently: How to tag questions about "C with a little C++". This is something of a hot potato that causes friction between new users and veterans. In addition, using both tags often causes irrelevant answers to pop up. In order to avoid this, clearer policies are needed.

I made proposed guidelines as a community wiki in the linked thread, but without much feedback from other users. So before I update the wikis, I would like to get feedback from the C and C++ communities.

Proposal

  • We synchronize the tag usage wiki of and so that they are consistent with each other.
  • We should update both tag wikis with specific rules for cross-tagging with both C and C++ tags.
  • The part of the C wiki called "Is it C, C++ or both?" will be removed and replaced with the policies below.
  • The part of the C++ wiki called "Have a question?" will be removed and replaced with the policies below.

New proposed tag usage policies:

Tag usage

When posting questions about C programming, please make sure to include:

  • Target system and compiler information. This includes the compiler name, version and settings used to compile.
  • If your question is specific to one particular version of the the language, add or . Pre-standard, historical questions should be tagged .
  • Unless the question explicitly mentions which version of the C standard that is used, it is assumed that the current version is used. That is, whichever version of ISO 9899 that ISO currently lists as active. Please have this in mind when answering or commenting on questions tagged .

-

Tag usage

When posting questions about C++ programming, please make sure to include:

  • Target system and compiler information. This includes the compiler name, version and settings used to compile.
  • If your question is specific to one particular version of the the language, add or . Questions about boost should add the tag .
  • Unless the question explicitly mentions which version of the C++ standard that is used, it is assumed that the current version is used. That is, whichever version of ISO 14882 that ISO currently lists as active. Please have this in mind when answering or commenting on questions tagged .

Then add this same text to both C and C++ tag wikis:

Using and together
C and C++ are two distinct and often incompatible languages. Avoid using both tags in the same question unless you have good reasons.

A question should be tagged with only, if:

  • It contains pure C, with no trace of C++, or questions with code that could be either language.
  • The code is compiled with a C compiler.

A question should be tagged with only, if:

  • It contains code with any C++ features. Even though the code may be "C style".
  • The code is compiled with a C++ compiler.

A question should be tagged with both and if it is about:

  • Specific differences between C and C++.
  • Compatibility or porting code between C and C++.
  • C++ code that uses C libraries (for example code using extern "C").

-

Editing and moderation guidelines for posts with both and tags:

To edit/re-tag/moderate questions with both tags, it is recommended that you have full edit privileges and either a gold or a gold badge.

If you encounter a post with both tags, edit/re-tag it if needed according to the above rules. If you can tell the language by reading the posted code, simply edit tags accordingly. Avoid prompting the user "is it C or C++?" in comments unless the question is truly unclear.

One example of an unclear question is when the user explicitly claims that they are programming in C, but posts code or compiler messages for C++. If so, prompt for clarification and close-vote as unclear.

"Either C or C++ is fine" opinions from the OP is a strong indication of a poor or unclear question. Answers may be very different depending on language picked. Prompt for clarification, close as unclear/too broad until the OP has clarified this.

Be careful about re-tagging questions once there are answers posted, particularly if there are already both C and C++ answers posted. In such cases, the tags should be left alone, since changing them would make posted answers invalid.

Answers with C++ code to a C question that has never been tagged should be deleted as off-topic. Please check question edit history before flagging/deleting such answers, to verify that the question never had the C++ tag.


Please post feedback & proof-reading below. I'll let this post sit on meta for at least a week before changing tag wikis.

22
  • 5
    To me, "Moderator guidelines" reads as is it is directed at moderators as in diamond mods. Would "Editing guidelines" be better? Also, "either a gold c or a gold c++ badge" makes me wonder about if I had both. Commented Sep 20, 2018 at 13:43
  • 11
    Or "Moderator guidelines" -> "Moderation guidelines" Commented Sep 20, 2018 at 13:44
  • 3
    Yeah agreed. Perhaps just "Re-tagging guidelines?" Even though I tossed in some misc close/delete advise there too.
    – Lundin
    Commented Sep 20, 2018 at 13:47
  • 2
    What about "Editing and Moderation Guidelines"? Or "Guidelines for Editing, Tagging, and Moderation"? Commented Sep 20, 2018 at 15:05
  • 2
    Please replace c90 with c89 in your policies.
    – Cœur
    Commented Sep 20, 2018 at 16:35
  • 1
    I like this very much, but I would really like if you finished the “Use C and C++ together” box with the sentence “Otherwise, do not use both tags at once.”
    – fuz
    Commented Sep 20, 2018 at 16:53
  • Suggest for both C and C++ tag usage: "If possible, mark the line in the code that gives the warning/error with a comment".
    – AdrianHHH
    Commented Sep 20, 2018 at 17:05
  • 4
    @Cœur: C90 is the ISO standard; C89 is the US-only ANSI standard for C, essentially equivalent to C90. C90 is a better choice than C89, IMO. Commented Sep 20, 2018 at 19:47
  • @fuz Indeed, we should add something like that, to discourage unnecessary use. It's in line with the proposal of Nicol Bolas below.
    – Lundin
    Commented Sep 21, 2018 at 6:37
  • 3
    Good thing the communities of C and C++ take action here. But how many people do you expect to read the tag wiki's? And how many of those are new-users? Sorry to play the devils advocate here ;)
    – Luuklag
    Commented Sep 21, 2018 at 7:25
  • 3
    @Luuklag It's more about agreeing over a policy and then document it somewhere. It's a whole lot better than hearsay and various users personal opinions, which is mostly how issues like these are moderated currently.
    – Lundin
    Commented Sep 21, 2018 at 8:33
  • I think, since few people read tag wikis and fewer read edit logs, if the reason for a tag change is that official - it might be a good thing to promote reading the tag wiki, by dropping a comment, pointing to the tag wiki.
    – derM
    Commented Sep 21, 2018 at 9:22
  • About the part that says "questions with code that could be either language." being marked with only the c tag. I think I understand the motivation. But I see a problem with questions where the answer is the same for both languages and which may be of interest to developers using either one. For example, this popular c question can also be very useful for c++ developers. Removing the c++ tag may make it harder to find for those users. Commented Sep 25, 2018 at 12:07
  • And this question is the fourth most upvoted c question, despite having c++ code in the question. I'm not sure what to make of it with these guidelines. Commented Sep 25, 2018 at 12:08
  • 2
    We should not pick C++ questions as a dupe for C - that's pretty much de facto policy even though I'm not sure if we have a meta thread about it. The other way around can be appropriate if the answer is the same in C and C++.
    – Lundin
    Commented Sep 25, 2018 at 13:03

4 Answers 4

18

I think the usage sections have too much needless verbiage or present information best stated elsewhere.

For example, MCVEs are appropriate for all debugging questions, not specifically those of C and C++. So putting a reminder on the tag wiki pages for them doesn't really make sense. The admonition about compiler errors/warnings is similarly broadly applicable to every compiled language tag. Do we really want to go around and stick that onto every tag wiki page?

So, the usage would be better presented as:

Tag usage

When posting questions about C++ programming, please make sure to include:

  • Applicable compilation information. This includes compiler versions, flags/switches, and so forth.
  • If your question is about a specific version of C++, add the appropriate tag: , , , , or . Questions about boost should add the tag .

And something similar can be done for the C version. Keep things as brief as possible, while getting the necessary information out there.


As for the cross C/C++ guidance, I think you're burying the lede. The most important advice is when to use both tags. Or more specifically, when not to. And similar to the above, we don't really need guidance on when to use a particular language tag when posting a question about that language, so those sections can be removed. Focus on the case people don't understand: when to use the two language tags together:

Using and together
Do not tag a question as both C and C++ unless the question is specifically about both languages. In particular, do not tag a question with both just because:

  • C++ code is written in a "C style" (using idioms common to C that are generally avoided in modern C++) or could be compiled as C.
  • C code that could compile as C++ with the same behavior.

Only use both tags in the following cases:

  • Questions regarding specific differences between C and C++.
  • Questions regarding compatibility or porting code between C and C++. This includes cases where you specifically need your code to compile under both languages, with the same behavior.
  • Questions regarding C++ code that uses C libraries (for example code using extern "C").
7
  • 2
    Good feedback. Notably, a lot of the proposed text is a copy/paste of what's already present on the wikis, with the MCVE and so on. I do agree that general advise about posting a question on SO should be removed. Regarding multiple tags, there's a whole lot of strange scenarios. We have people thinking they compile in C which in fact they are compiling in C++. We have people thinking they program in the "C/C++ language". We have people thinking the languages behave identical for their specific issue, while in fact they don't. And so on. I agree that we should minimize the text however.
    – Lundin
    Commented Sep 20, 2018 at 15:42
  • While I agree that some of the per-tag usage is technically redundant, the chances are rather too large that people won't be aware of it, so adding the information to the Wikis helps ensure that the information (about including platform and compiler version information, exact error messages, and using an MCVE) are not necessarily all bad. It makes "go read …" messages to those who abuse the system easier. OTOH, I'm not going to get hung up on this – and the C wiki is fairly extensive already. The 'both tags' revision is pretty good. Commented Sep 20, 2018 at 16:05
  • 3
    @JonathanLeffler: The problem with Tag Wiki's in general is that they're not really discoverable. They're something you barely even notice as a new user; they're mainly something that more experienced SO users know about. They're not indexed in search, they're not easy to find, new users who put the tags on their questions don't even see the main wiki article, etc. And more experienced users already know about our MCVE rules. Indeed, its more likely that a new user will get their question closed as lacking an MCVE than they are to have even read the C or C++ tag wiki. Commented Sep 20, 2018 at 16:29
  • @NicolBolas: Yes — you're right, and as I wrote the comment I realized that was a valid concern (it's one reason for the "I'm not going to get hung up on this" part of my comment). Maybe there's a link that can be used instead of verbiage in the Wiki to the requirements — in programming terms, a link acts a bit like a subroutine call and saves on repetition in the code (wiki). Commented Sep 20, 2018 at 16:32
  • 2
    The 3rd bullet point in the list of combined c++ and c usage should be more generic in requiring any interop scenario (using C code from C++, calling C++ code from C, creating a C compatible interface for C++ code). Commented Sep 21, 2018 at 8:43
  • "They're not indexed in search" [citation-needed] They are indeed indexed meta.stackoverflow.com/a/370472/792066
    – Braiam
    Commented Sep 21, 2018 at 13:00
  • I have integrated the first part of this answer into the proposal. The second part I don't agree with though, after consideration. It is important that we state what to do with questions that are already incorrectly tagged. For that, we need rules about when a question should be C only and when it should be C++ only.
    – Lundin
    Commented Sep 27, 2018 at 13:02
4

After some thought, I think we should add the part from the notes in my previous (now community wiki) suggestion:

"Either C or C++ is fine" opinions from the OP is a strong indication of a poor or unclear question. Answers will be very different depending on language picked. Prompt for clarification, perhaps close as unclear/too broad until the OP has clarified this.

Not only because answers may be very different, but also because this isn't a pizza store where you get to order your favourite flavour. Correct me if I'm wrong, but any question that has to prompt "either C or C++ is fine" is some manner of write-the-code-for-me request.

If the OP included a MCVE, they should have a solution in the same language as that code. If not, the question is most likely just code begging and should be closed as too broad/unclear.

3
  • "any question that has to prompt "either C or C++ is fine" is some manner of write-the-code-for-me request." It's more that they either 1) don't really know what they want, or 2) don't understand the distinction enough to be able to know what they want. Either way, they aren't asking a complete question. Commented Sep 27, 2018 at 13:49
  • @NicolBolas The need for this mostly originates from code-beginning questions where the OP didn't even write a single line of code. This is common. And well, if a person doesn't even know what language they are programming in, there is no hope of them writing any form of useful software. It's like calling the mechanic and ask if they can fix your car, without even knowing which car model you own, or how to drive it.
    – Lundin
    Commented Sep 27, 2018 at 13:57
  • Almost always the "Either C or C++ is fine" questions seem to really ask for for a "C++ or Archaic C with silly casts everywhere that is approved by my bad C++ compiler". Commented Sep 28, 2018 at 12:10
3

I'd like to suggest some word-smithing on the 'one or both' tags section of the revised proposal. The current proposal uses 'The following' to introduce the topics, which is rather passive compared with this revision:


A question should be tagged only if:

  • It contains pure C with no trace of C++, or code that could be either language.
  • The code is compiled with a C compiler.

A question should be tagged only if:

  • It contains code with any C++ features, even though the code may be "C style".
  • The code is compiled with a C++ compiler.

A question should only be tagged with both and if it is about:

  • Specific differences between C and C++.
  • Compatibility or porting code between C and C++.
  • C++ code that uses C libraries (for example code using extern "C") or vice versa.

(I added the 'or vice versa' to the last bullet; I think it's valid, but I won't be devastated if it is omitted.)

I'm not sure if we need to explicitly state the connective between the bullet points within each set; it's an 'inclusive or', I believe, rather than an 'and'.

The 'only' in the 'A question' lines could be moved within each line, with subtle differences of emphasis (and maybe elements of ambiguity, which should be avoided if possible):

A question should be tagged only with if:

A question should only be tagged with if:

A question should be tagged only with (and not with ) if:

The verbiage could also use a few extra words to be more pedantically explicit.

A question should be tagged with only the tag (and not the tag) if:

A question should be tagged with the tag only (and not the tag) if:

The parenthetical comments could be omitted if preferred.

There should be maximum symmetry between the three introducer ('A question …') clauses (especially the first two), without losing the main point.

1
  • Since this is mostly just better English with no technical/moderation differences, you could just go ahead and edit it in with the question (we should make it community wiki). I have updated it with your proposal. I went with "...tagged c only, if", using the comma to dodge the ambiguity with "only if". (Adding the comma operator to introduce a sequence point before the next if statement :P)
    – Lundin
    Commented Sep 28, 2018 at 6:47
2

I have updated the C and C++ tag wikis according to the proposal. Changes are live.

  • The question has now been flipped to community wiki and may be maintained by anyone.

  • I added the tag usage policy regarding which standard is regarded as default for C and C++ questions, as per community consensus here: C tag usage, radical changes to tag wiki. Which policy to keep?

  • I will also go through previous meta discussions about the C vs C++ tagging issue and close them as dupe to this one, if needed. It would be great if we could centralize future discussion about cross-tagging to this post.

3
  • Considering the C standard library (often a C library, but need not be) is subsumed into the C++ standard library (hard to not write most of that as a C++ library), I wonder if any C++ question can, considering the guidance, be considered mis-tagged if also tagged C. Commented Sep 1, 2020 at 20:05
  • @Deduplicator The C language itself is different and not compatible with C++ in many and often subtle ways. Most but not all C libraries are included in C++. Also, C programmers are not necessarily interested in reading C++ posts.
    – Lundin
    Commented Sep 1, 2020 at 20:57
  • You are making my argument for me! Just because it uses a C library does not mean tagging C makes any sense, despite what the tag-wiki now says. Commented Sep 1, 2020 at 21:15

You must log in to answer this question.

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