I have seen .cc for C++ and it annoys me, but seems rather common.
I have seen .cc for C++ and it annoys me, but seems rather common.
No[1]:
> C++ source files conventionally use one of the suffixes `.C`, `.cc`, `.cpp`, `.CPP`, `.c++`, `.cp`, or `.cxx`; C++ header files often use `.hh`, `.hpp`, `.H`, or (for shared template code) `.tcc`; and preprocessed C++ files use the suffix `.ii`. GCC recognizes files with these names and compiles them as C++ programs even if you call the compiler the same way as for compiling C programs (usually with the name gcc).
[1] https://gcc.gnu.org/onlinedocs/gcc/Invoking-G_002b_002b.html
So to make the implied answer to the question explicit: no, it's because someone who knew the difference between C and C++ sought to distinguish between their source code files using a filename extension convention that becomes invisible on a different OS.
Not even close. C++ is a vastly more complex language with a very different philosophy from that of C.
You might argue that C can very roughly be treated as a subset of C++, but this really is a very rough approximation. Which is to say, really, that it's wrong.
> And they inter-link
It's generally very easy to call C code from C++ code, yes. It is not easy to call C++ code from C.
Well, 99% of the time this holds, and you can generally use the same tooling in different modes for both. And they share a preprocessor.
> It's generally very easy to call C code from C++ code, yes. It is not easy to call C++ code from C.
Significantly easier than almost any other pair of languages, though. Especially if you take a little care on the C++ side (extern "C") or use COM or similar.
Again, C is more compatible with C++ than python 2 is with python 3. But not the other way round.
> Significantly easier than almost any other pair of languages, though.
I wouldn't say so. If you're using the features of C++ then you'd need to manually wrap it all to expose a C API.
Accessing C code from C++, Ada, Rust, Zig, Java, Python, C#, or just about any other language, would be easier than manually wrapping C++ to expose a C API.
(The LLVM compiler, written in C++, does this. It exposes a subset of its API as a C API. I get the impression it's no small task, or they'd expose the full LLVM library that way.)
> Especially if you take a little care on the C++ side (extern "C") or use COM or similar.
Agreed, but going the extern "C" route implies you're using C++ as a better C, rather than making full use of C++. I have to admit I don't know much about working with COM. It's vaguely like GObject, right? I imagine it must take quite a bit of work to expose a C++ API that way.
Nobody thinks that. Everybody knows what it means. Picking on it is like picking on people referring to amd64 as x86.
I'd happily apply for a "C/Rust" job as well.
Well, MSVC compiles .c files as C, which I guess makes it also a C compiler? It supports most of C99 by now.
> MSVC doesn't officially support C to this day.
Oh, it does: https://docs.microsoft.com/en-us/cpp/build/walkthrough-compi...