I have a .cpp source file that contains both C and C++ code. The C code does not compile using g++ so I need to use gcc.
Using extern "C" {} does not work because that’s just to tell the compiler how to handle the function names, I want g++ to behave like gcc entirely for one portion of the code, and like g++ for another.
I know I could just put them on separate files, but then I would have to create a header for the file with the C code to be able to use it in the other C++ file and that is what I’m trying to avoid. I don’t want those functions visible to anyone other than that C++ code.
Does that make sense? Is this even possible? Thanks!
Put them in separate files and declare the functions in the file with the C++. You don’t need to create a header.
C++ code (blah.cpp):
C code (blah.c):