After converting a piece of C++ code to C one of the functions that are generated is this: _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc Where is it defined and where can I find the source for it? I need the source to compile it with a C compiler (AMPC) that will convert the C code to Java Bytecode. If the above function is in C++ then I need to convert it to C first. Here's the code segment that uses the function: int main(void) { struct l_struct_2E_std_3A__3A_basic_ostream_3C_char_2C_std_3A__3A_char_traits_ 3C_char_3E__20__3E_ *ltmp_2_2; CODE_FOR_MAIN(); /*tail*/ __main(); ltmp_2_2 = /*tail*/ _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(( &_ZSt4cout), (&(_2E_str_1[0]))); return 0; } Thanks for any tips. Napi
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? -- John T.>Where is it defined and where can I find the source for it? I need the >source to compile it with a C compiler (AMPC) that will convert the C >code to Java Bytecode. If the above function is in C++ then I need to >convert it to C first. > >Here's the code segment that uses the function: > >int main(void) { > struct >l_struct_2E_std_3A__3A_basic_ostream_3C_char_2C_std_3A__3A_char_traits_ >3C_char_3E__20__3E_ *ltmp_2_2; > > CODE_FOR_MAIN(); > /*tail*/ __main(); > ltmp_2_2 = /*tail*/ >_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(( >&_ZSt4cout), (&(_2E_str_1[0]))); > return 0; >} > >Thanks for any tips. > >Napi > >_______________________________________________ >LLVM Developers mailing list >LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >
On Fri, 17 Nov 2006, 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_PKcThis is defined in the C++ standard library. You can get the demangled name like so: $ c++filt _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char>>&, char const*)> Where is it defined and where can I find the source for it? I need the > source to compile it with a C compiler (AMPC) that will convert the C > code to Java Bytecode. If the above function is in C++ then I need to > convert it to C first.It comes with llvm-gcc4 in libstdc++. You'll need to compile it to bytecode by modifying the makefile though. -Chris -- http://nondot.org/sabre/ http://llvm.org/
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
On Thu, 2006-11-16 at 21:08 -0800, Chris Lattner wrote:> On Fri, 17 Nov 2006, 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 defined in the C++ standard library. You can get the demangled > name like so: > $ c++filt _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc > std::basic_ostream<char, std::char_traits<char> >& std::operator<< > <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> > >&, char const*) > > > Where is it defined and where can I find the source for it? I need the > > source to compile it with a C compiler (AMPC) that will convert the C > > code to Java Bytecode. If the above function is in C++ then I need to > > convert it to C first. > > It comes with llvm-gcc4 in libstdc++. You'll need to compile it to > bytecode by modifying the makefile though.Thanks. Do I need to deal with the long names like _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc() or is there an option to use the shorter version? Cheers. Napi