Is there a way to compile C++ to C Code?

cl_progger picture cl_progger · Feb 19, 2011 · Viewed 21.1k times · Source

I have a program which is configured by the user by using C++ classes and the same class should be used to configure a program which can only use a subset of C99 (Open CL Language).

So my question is: Is there a way to compile C++ to C-Code?

Open Source would be great!

Answer

tonio picture tonio · Feb 19, 2011

You could use the clang C++ frontend to generate llvm bytecode, and use llc to emit C code, see llc doc, especially the c option. Both are open source, with BSD like licenses.