[LLVMdev] C++ -> C translation problems

Jeff Cohen jeffc at jolt-lang.org
Sun Apr 8 09:38:26 PDT 2007


Forget it, it's not going to work... period.

The C code generated from C++ is going to have massive dependencies on 
the GCC run time library.  Even if it compiled, it will never link with 
either BCC or MSVC.

I don't know or use Borland's compiler, so I can't help you there.  But 
Microsoft's C compiler does understand "long long".  I just tried it.  
You may be using an older compiler.  We only support .NET 2003 and later.

Mauro Condarelli wrote:
> Hi All,
> I am trying to use llvm compiler to translate a non-trivial piece of code from C++ to C.
> I need this because I need to use part of the code as lib for another project that is strictly C.
> I am working under MSWin and I have choice to use either BCC or MSVC.
>
> After a good deal of tries I found out I had to somewhat massage llc -march=c output to make it *almost* compilable.
>
> I have one residual problem I'm unable to overcome :(
>
> I reduced the test program to real minimal version:
> ===================================================
> class File {
> public:
>    File() {}
>    virtual ~File() {}
> };
>
> class showError : public File {
> public:
>    showError(void);
>    ~showError(void);
> };
>
> showError::showError(void) {
>    //
> }
>
> showError::~showError(void) {
>    //
> }
> ===================================================
> The acid is the "virtual" specifier in "virtual ~File() {}". If I remove it then BCC32 compiles the resulting program, else it bombs with "Error E2063 terr.c 153: Illegal initialization".
>
> For the whole compilation I use the following .bat file:
> ===================================================
> rm err.bc
> .\..\..\LLVM\bin\llvm-g++ -I../LLVM/include -Wno-deprecated -I../unrar -emit-llvm -c err.cpp -o err.bc
> rm err.cbe.c
> .\..\..\LLVM\src\llvm-1.9\Release\bin\llc -march=c err.bc
>
> sed "s/!defined(_MSC_VER)/!defined(_MSC_VER) \&\& !defined(__BORLANDC__)/" err.cbe.c >t1
>
> sed "s,__stdcall ,/*__stdcall*/ ,g" t1 >t2
> sed "s/_$_/_S_/g" t2 >t3
> sed "s/_2$_/_2S_/g" t3 >terr.c
> rm t1 t2 t3
> "C:\Program Files\Borland\BDS\4.0\bin\bcc32" -I"C:/Program Files/Borland/BDS/4.0/include" -I../unrar -p- -c terr.c
> ===================================================
>
> I won't send the (rather long) terr.c, but it is (obviously) available on request.
>
> The offending line is:
> ===================================================
> ..
> /* Global Variable Definitions and Initialization */
> vvvvvv this is the culprit vvvvvv
> struct l_struct_2E___si_class_type_info_pseudo _ZTI9showError __ATTRIBUTE_WEAK__ = { { ((signed char *)(((unsigned )(&_ZTVN10__cxxabiv120__si_class_type_infoE)) + 8u)), (&(_ZTS9showError[0])) }, ((struct opaque_0 *)(&_ZTI4File)) };
> ^^^^^^ this is the culprit ^^^^^^
> signed char _ZTS9showError[11] __ATTRIBUTE_WEAK__ = "9showError";
> ..
> ===================================================
>
> I'm using latest stable version (I downloadad it last week).
>
> Also cl doesn't work; first problem is it doesn't like "long long"...
>
> Please HHHEEEEEELLLLLPPPPPPP!! :)
>
> Best Regards
> Mauro
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
>
>   




More information about the llvm-dev mailing list