11

I come across many asked/tagged questions for which there already exists many duplicate posts but sometimes those posts are tagged with only .

For example, suppose a user asks a C++ tagged question saying ternary operator does not work with the following code:

cout << endl;
(afterCalc)? goto calcStart : continue;

Now the above is clearly a C++ question (as it uses cout). Now after searching for duplicates I came across many posts and 2 of them were tagged only and the solutions/explanations provided there are applicable to this post also. Here are the duplicates that are only tagged:

goto not working with ?: operator in C

Can I use a continue statement in a ternary operator ? (C)


Now, my question is, can this post (the one I showed as an example) be closed as a duplicate of the two posts that are only C tagged.

Note that the tag wiki says:

Code that works the same in both languages should be tagged C unless the OP explicitly says that they are compiling it with a C++ compiler, in which case it should be tagged C++ and not C. It's all in the tag wiki.

(emphasis mine)

So as per my understanding since the code works the same in both languages, by definition it should be possible to close the post as a duplicate of the posts tagged only . That is, as long as the solution and the problem applies to both the languages and the concerned problem can be solved by them, one should be able to closed as a duplicate of the other.

6
  • "Now the above is clearly a C++ question(as it uses cout)." I question the "clearly". Clearly it's a question which has C++ code, but that doesn't mean it's a question about C++. If instead of cout ... it had francescalus_super_lib_call() would the question suddenly be about the library I wrote last night? May 25 at 15:55
  • 4
    @francescalus It is clearly a c++ question because cout will work with a C++ compiler. That is why this example question can't be tagged c. In particular because a c compiler will reject the code.
    – Jason
    May 25 at 15:58
  • 2
    Very related meta.stackoverflow.com/questions/270527
    – cigien
    May 25 at 16:04
  • I won't claim that it's C code, or that c would be acceptable. But I also don't see that cout << 0.1+0.2 // Why not 0.3??? :* is automatically a question which is uniquely answerable in the C++ domain. May 25 at 16:05
  • 5
    can it be? sure... should it be? no... even if an answer in language B can work in language A, that doesn't mean it's necessarily the best option for that language. Keeping these separate allows them to be updated in the future in a way that is less confusing if one or the other gains a better way of solving the problem.
    – Kevin B
    May 25 at 16:07
  • 2
    The conditional operator is perhaps not the best example here because there are some very significant differences between C and C++, in terms of how it is parsed. May 26 at 16:56

2 Answers 2

3

Do keep in mind that we are closing questions as duplicates based on the applicability of answers on the duplicate target (see the appropriate section of the closure guidance), therefore it does not matter how the target is tagged. As long as a solution on the duplicate target is applicable one-to-one, close the question with confidence.

2

Is there one of the answers at the other question that answers this one exactly? Pay particular attention to code snippets and names of things being called when deciding this. Merely being "the same sort of thing" isn't suitable as a duplicate, but using different variable names usually is. You probably also ought to consider whether the answer would also be good style. (Between most languages this isn't going to be the case, but C and C++ are a special case.)

If one of the answers there answers this question properly too, you've got a genuine duplicate and should vote to close.

You must log in to answer this question.

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