[LLVMdev] C++ to C

Mohd-Hanafiah Abdullah napi at axiomsol.com
Fri Nov 17 00:32:23 PST 2006


On Thu, 2006-11-16 at 22:59 -0600, John T. Criswell wrote:
> Mohd-Hanafiah Abdullah wrote:
> 
> >After converting a piece of C++ code to C one of the functions that are
> >generated is this:
> >_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc
> >  
> >
> This is a method/function from the standard C++ library.  You can link 
> it in at the bytecode level with:
> 
> llvm-g++ -o output.bc <yourfile.bc> -lstdc++
> 
> You might also be able to do:
> 
> llvm-g++ -o output.bc <yourfile.bc> -lsupc++
> 
> ... if you're only doing minimal C++ work.
> 
> One caveat: you will still have references to external C library 
> functions (fopen(), open(), etc) that will not exist in the C output 
> from the llc command.  Can your C to Java Bytecode compiler handle calls 
> to these functions?

Yes, AMPC handles calls to these functions.  It supports ANSI C 1989.
The only functions in the standard C library that are not supported yet
are raise(), signal(), longjmp(), and setjmp().  Others work fine.

The purpose of my using LLVM is to convert C++ to C, then compile it
using AMPC and link it with the standard C library that has already been
compiled for the JVM also with AMPC.  So, now I guess I will have to
also compile the C++ standard library to the JVM in order to support
functions like:
_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc().

Cheers.

Napi





More information about the llvm-dev mailing list