0

I am working on a project that I am writing in C++ but I am using some helper functions that were written in C. Since everybody is saying that compiling C source code with g++ is a big nono, is there a safe way to work with both C and C++?

  • https://isocpp.org/wiki/faq/mixing-c-and-cpp – Cory Kramer May 06 '20 at 19:47
  • 3
    Ask "everybody" to explain **why** they say you shouldn't do it. In general, mixing C and C++ works just fine; there are no lurking dragons. – Pete Becker May 06 '20 at 19:49
  • 1
    There are ways to "mix" almost any two (or more) languages. – Eugene Sh. May 06 '20 at 19:52
  • *Since everybody is saying that compiling C source code with g++ is a big nono* -- Only if that `C` code contains `C` anachronisms such as missing prototypes, `malloc`'s without the return value casted, and a whole lot of other `C` things that C++ won't accept -- then you have no choice but to change the C code. The only way you will know is to compile the C code as C++ and see. But in general, mixing C and C++ is perfectly fine, if you know what you're doing. – PaulMcKenzie May 06 '20 at 20:12

0 Answers0