[LLVMdev] LLVM: C++ -> C

dilas dilas espiritusantu at mail.ru
Tue Sep 29 09:37:50 PDT 2009

I've read that LLVM can convert from C++ to C code.
So I've used it in such a way:
I'm Windows-user so I used MinGW.
I employed this file as the test:


#include <iostream>

int main(int argc, char* argv[])
	return 0;

result of "llvm-g++ C:\llvm_hello.cpp -o C:\llvm_hellopp.exe" worked just fine.

as a result of "llvm-g++ -O3 -emit-llvm C:\llvm_hello.cpp -c -o C:\llvm_hellopp.bc" and 
"llc -march=c C:\llvm_hellopp.bc -o C:\llvm_helloCppToC.c" I obtained this charming stuff:
And after "llvm-gcc C:\llvm_helloCppToC.c -o C:\llvm_helloCppToC.exe"
I've got:
"C:\llvm_helloCppToC.c: In function 'main':
C:\llvm_helloCppToC.c:180: warning:return type of 'main' is not 'int'
C:\...\Temp/ccfREe4x.o:fake:(.text+0xae): undefined reference to 'std::ios_base::Init::Init()'
C:\...\Temp/ccfREe4x.o:fake:(.text+0xbe): undefined reference to 'std::ios_base::Init::~Init()'
collect2: ld returned 1 exit status"
What I've done wrong?

More information about the llvm-dev mailing list