What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 134 Stack Exchange communities.

Sometimes, there will be a question with the C++ tag. But the code that the asker uses will just so happen to also be valid C code. For example, they will use printf instead of cout. Then someone comes along, without consulting the OP, and modifies the tags, and possibly the title and/or body, and makes it a C question. This is, in my opinion, not correct behavior, but I would like verification. The following questions all assume that the code in the question is valid both as C and C++ code, and that the potential modifier has not consulted the OP.

  1. When there is only a C++ tag, is it okay to remove the C++ tag and replace it with a C tag?
  2. When there is only a C++ tag, is it okay to add a C tag?
  3. When there is both a C++ tag and a C tag, is it okay to remove the C++ tag?
share|improve this question
4  
@Samiam not sure we need a meta tag c ... –  AakashM Dec 12 '12 at 15:59

3 Answers 3

up vote 14 down vote accepted

Double-tagging is seen very often and predominantly from new users with little evident experience in the language they're using. In the mean / case, I don't trust the OP to have chosen those two out of wisdom. Of course sometimes it happens, but more often than not, when I see both tags, I have to look a bit closer to find out whether one can be removed, because it's rare that both belong on a question.

My tuppence followeth…


1. When there is only a C++ tag, is it okay to remove the C++ tag and replace it with a C tag?

Only if the OP has stated (or it is clear from e.g. compilation commands) that the code is being compiled as C. If it is C-like C++ code then it is absolutely not appropriate to remove the tag; however, the OP should be informed via comments that they're learning C++ wrong.


2. When there is only a C++ tag, is it okay to add a C tag?

No! A C++ question is a C++ question, end of story.

(If the question body appears to suggest that C may be relevant — for example, a question about a comparison between the two languages — then that is obviously a special case, but a clear-cut one.)


3. When there is both a C++ tag and a C tag, is it okay to remove the C++ tag?

Unless both languages are obviously relevant (again, a comparison between them would be an example of this), then yes but usually not without getting the OP's opinion first. I always ask the OP whether they are programming in C++ or C, and to choose one tag to use, then when they tell me I will remove the incorrect tag.

(One notable exception to this "get the OP's opinion first" rule is when their intent is already properly clear from the question body, e.g. C Weird & interesting program output)

Occasionally they will explain that it is a hypothetical question and that they want an answer for both languages, at which point I say "this should be two questions", but generally leave it alone.

share|improve this answer
    
So from your answer it sounds like I was being too aggressive in retagging this question from C++ to C? –  Shafik Yaghmour Jan 15 at 15:40
    
@ShafikYaghmour: Yes, I think so. I understand why would you want to, and the benefits you see in it. In this case, really, we need the OP to listen to us and go "right, okay, good point — let me abstract the C++ from this question and we can pretend I'm using a C compiler from now on", then re-tag. –  Lightness Races in Orbit Jan 15 at 15:47
    
Fair point, that makes sense. –  Shafik Yaghmour Jan 15 at 16:02
1  
I took C++ off a question (stackoverflow.com/questions/21139988/…) today, because the asker put C in the title, and the code was not using any C++ features. I think this was the right thing to do in that case. I wouldn't have done it if the title or body hadn't specifically said C though. –  Kate Gregory Jan 15 at 16:15
    
Agree in the most part. I feel it is (almost) never appropriate to change a language tag without first consulting with the OP to clarify either their intent or their lack of understanding. In the latter case the wisdom of the community should be relied upon. In your clause under #3, "Essentially. [...]" it was unclear to me if you were suggesting this tag change should be made without consulting the OP. I know that you consult the OP, but I'm not sure if you're saying everyone should. –  John Dibling Jan 15 at 16:17
    
@KateGregory: I think it was appropriate in this case. The title and body both explicitly say they are programming in C only, and there is no mention of C++ anywhere except the tag. –  John Dibling Jan 15 at 16:19
    
@KateGregory: Yep, couldn't agree with you more there. –  Lightness Races in Orbit Jan 15 at 16:39
    
@JohnDibling: Better now? –  Lightness Races in Orbit Jan 15 at 16:41
    
@LightnessRacesinOrbit: Great. Would upvote now if I hadn't already. –  John Dibling Jan 15 at 16:49
    
@JohnDibling: Thanks for the suggestion =) –  Lightness Races in Orbit Jan 15 at 16:56

The earlier answers assume that the poster actually understands the difference between C and C++. Unfortunately a lot of posters on SO are noobs/students who happen to be using e.g. MSVC++ or Turbo C++ but they are actually working through a C book, e.g. K&R, and posting small C code examples that they happen to be compiling with a C/C++ compiler. The essence of the question is about C, but the compiler happens to have C++ in the name and so they unwittingly tag the question as C++. I would argue that such questions should be retagged as C when it's clear that the question is fundamentally about the language (C) rather than the compiler (C/C++).

share|improve this answer
6  
Confirm with the OP though. Explain the difference if you must. Don't just assume that they are "noobs/students". –  Bart Dec 12 '12 at 16:46
    
Yes - fair point I suppose, but more work - in some cases it's obvious because e.g. it's a code example straight out of K&R. I shall resist the urge to re-tag in future. –  Paul R Dec 12 '12 at 16:49
    
It's tempting and I made the mistake before. Better safe than sorry (and confusing to those who answer) –  Bart Dec 12 '12 at 17:55
1  
I'd argue that if you think that they're using a c++ compiler than you should absolutely NOT remove the c++ tag –  Sam I am Dec 13 '13 at 21:08
    
-1: when it's clear that the question is fundamentally about the language (C) rather than the compiler (C/C++) What you're compiling as is the very definition of "what language am I using?" (knowingly or otherwise). –  Lightness Races in Orbit Jan 15 at 15:30
    
@LightnessRacesinOrbit: I disagree - if you're using malloc/printf/pointers/etc, and no C++-specific features at all, then it's just plain C, regardless of what compiler you happen to be passing it through. –  Paul R Jan 15 at 16:18
    
@PaulR: That is simply patently false. All those features exist within the C++ language. Just because they exist in C as well isn't a reason to spontaneously change the context of the question, away from the language actually being used by the OP, for the sake of it. If you need a practical reason then it may be that a C answer misses some nuanced difference to these features in C++. –  Lightness Races in Orbit Jan 15 at 16:43
1  
@PaulR: Why is this logic only valid one way? That is to say, there are features in C which are not in C++, such as VLAs. Can I say "if you're using statically sized arrays and casting the return value of malloc, and no C specific features at all, then it's just plain C++" ? -- If not, why not? –  Benjamin Lindley Jan 15 at 16:45
    
inb4 "because C was first" which is not a reasonable argument –  Lightness Races in Orbit Jan 15 at 16:48
    
Even in many cases you mention, where a noob is working through a K&R book, if they are using a C++ compiler it is still a C++ program. I would expect this to be especially for noobs who may not realize that on certian compilers, even if you name the file "*.c" it is being compiled as C++ unless you go in to some project settings and explicitly change the compilation model. –  John Dibling Jan 15 at 17:05
    
OK - I'm obviously outnumbered. Let the line between C and C++ continue to be blurred then. –  Paul R Jan 15 at 22:09
1  
@PaulR: there is no fair point at all in what Bart said. It sounds like a nice PR message, but it really will not work in the practice. Your answer is good and experts ought to be able to improve the site. Most of the time, the newcomers will not even bother to reply. –  lpapp Jul 11 at 19:52

I'd say, no, it's not okay to replace a C++ tag with the C tag, or vice versa. This actually changes the language specified by the question.

As far as including them both, that's highly questionable, considering that nowadays you're encouraged to specify what language you're using with tags, and people who want to answer both probably follow both tags anyway.

It's also not okay to remove one of the tags if the OP included both. In this case the OP is looking for people with either expertise in C or C++, and by removing a tag, you remove some of the answerer base.

share|improve this answer
3  
It's also not okay to remove one of the tags if the OP included both. In this case the OP is looking for people with either expertise in C or C++ [citation needed] More often than not, this is not actually true. Besides, tags are for categorising the question, not recruiting answers. Might as well start tagging everything php if all you're using tags for is to reach the widest possible audience. –  Lightness Races in Orbit Jan 15 at 15:29

You must log in to answer this question.

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