We have policies in place for cross-tagging C and C++ and mixing the languages, which were fleshed out couple of years ago with community consensus here. The rules from there are now listed in the C and C++ tag wikis respectively, quoted below for your convenience:
Using c and c++ 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 c 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 c++ 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 c and c++ 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"
).
From this we may conclude that it is fine to ask "C style" questions using the C++ tag only, assuming that the code is compiled in C++, using extern "C" etc. There's no policy for "C style" answers but it seems reasonable that the same should apply there. C compatibility might be a valid concern. If not, it's mostly a matter of style and if you don't like an answer's style, you are free to down vote it. It's still a valid answer though.
With one exception, also from the tag wikis:
Editing and moderation guidelines for posts with both c and c++ tags:
/--/
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.
/--/
Answers with C++ code to a C question that has never been tagged c++ should be deleted as off-topic. Please check the question edit history before flagging/deleting such answers, to verify that the question never had the C++ tag.
That is, when someone who posts a C++ answer (or Java, C# etc answer) to a C question out of the blue. Be careful to check the edit history when that happens, since the question could originally have been tagged C++ and then the answer is fine.
If a question was always tagged C++ and someone drops a C only answer using features unique to C (VLA, _Generic etc) then such an answer would be equally off-topic.
The usual procedure for blatantly off-topic answers would be to down-vote, poke the poster with a comment to give them a chance to fix it, then if no reply after a long time, maybe start a "very low quality" delete procedure by flagging the off-topic answer.
c
, it will garner C answers. If the question is taggedc++
, it will garner C++ answers. If it is tagged with both, people will point out that those are two different languages and to figure out which one is relevant to the question.c
that are not valid inc++
like the VLAstry
andcatch
. Also, inheritance. These features require a change to the language so don't consider C++ as a superset of C. Another issue is function overloading.