What command and options should be used to convert C++ to C? Thanks
On 2008-10-10 21:29, Michael wrote:> What command and options should be used to convert C++ to C? >This works usually: llvm-g++ -O2 -c x.cpp -emit-llvm -o - | llc -march=c Or: llvm-g++ -O2 -c x.cpp -emit-llvm -o x.bc llc x.bc -march=c -o x.cbe.c However the resulting C file is not meant to be human-readable (or understandable). What do you need the C++ -> C conversion for? Best regards, --Edwin
On Friday 10 October 2008 20:29:49 Michael wrote:> What command and options should be used to convert C++ to C?Try this: llvm-gcc -c -O3 -emit-llvm file.cpp -o - | llc -march=c -o - It should spray C code to standard out. Ciao, Duncan.
On Oct 11, 2008, at 12:49 AM, Duncan Sands wrote:> On Friday 10 October 2008 20:29:49 Michael wrote: >> What command and options should be used to convert C++ to C? > > Try this: > > llvm-gcc -c -O3 -emit-llvm file.cpp -o - | llc -march=c -o - > > It should spray C code to standard out.Bear in mind that if you use features from the C++ library, you are still going to need a C++ library. llvm does not try to translate iostream into stdio calls or anything like that.