You can mix C and C++ code easily.
You should keep the C code to be compiled with C compiler (gcc), rest of the code can be C++ and be compiled with C++ compiler (g++). then link all object (.o) files together.
like this:
file name: a.c
const char* aTable[12] = {
[4]="seems",
[6]=" it ",
[8]="works",};
file name: b.cpp
#include <cstdio>
extern "C" const char* aTable[12];
int main(){
printf("%s%s%s", aTable[4],aTable[6],aTable[8]);
return 0;
}
Now compile:
gcc -c a.c -o a.o
g++ -c b.cpp -o b.o
g++ b.o a.o -o all.out
Now run the executable (all.out) and you’ll see that everything will work.
Just note that for functions you’ll need to add extern "C"
before the declaration in the cpp file.