4 ms·
it can also just indicate that when it was written it also had to compile as C++ for whatever reason.
by rrss 6y ago
it can also just indicate that when it was written it also had to compile as C++ for whatever reason.
- enriquto 6y agoThat's an even redder flat. Why would you even want or need that? I understand that sometimes it is convenient to write header files that can be read likewise by C and C++ compilers. But why would you ever need a piece of code to be compiled into an object by either C or C++ compiler, indistinctly?
- rrss 6y agoThere are several reasons why people would do this, but the decision is often not made by the person writing the code, so it may be a red flag to you, but it doesn't point to inexperience of the author. In addition to the MSVC issue mentioned in the sibling comment, I've worked on projects that used clang thread safety analysis, which at the time (and maybe still today) was only available for C++, so the build for that analysis was configured to build all C source files as C++.
- flohofwoe 6y agoThat was essentially Microsoft's advice because they didn't want to keep their C compiler uptodate: "We recommend that C developers use the C++ compiler to compile C code (using /TP if the file is named something.c). This is the best choice for using Visual C++ to compile C code." From: https://herbsutter.com/2012/05/03/reader-qa-what-about-vc-and-c99/ https://herbsutter.com/2012/05/03/reader-qa-what-about-vc-an...
- enriquto 6y agoI'm going to abstain from commenting on this topic. I am not emotionally prepared.
- deleted 6y ago[deleted]