translating oo features to C

Discussion in 'C Programming' started by dvanguard@gmail.com, Jan 31, 2008.

  1. Guest

    I was wondering if there are any open source compilers out there to
    translate the C++/Java/C#-like object model to C. Thanks,

    David
    , Jan 31, 2008
    #1
    1. Advertising

  2. Mark Bluemel Guest

    wrote:
    > I was wondering if there are any open source compilers out there to
    > translate the C++/Java/C#-like object model to C. Thanks,


    An early C++ "compiler" perhaps?

    As I understand it, C++ was initially precompiled to C source.
    Mark Bluemel, Jan 31, 2008
    #2
    1. Advertising

  3. Mark Bluemel wrote:
    > wrote:
    >> I was wondering if there are any open source compilers out there to
    >> translate the C++/Java/C#-like object model to C. Thanks,

    >
    > An early C++ "compiler" perhaps?
    >
    > As I understand it, C++ was initially precompiled to C source.

    'cfront' might be what you're looking for, although I guess the generatted
    code would be pretty illegibel to humans.

    Bye, Jojo
    Joachim Schmitz, Jan 31, 2008
    #3
  4. ppi Guest

    On Jan 31, 11:32 am, Mark Bluemel <> wrote:
    > wrote:
    > > I was wondering if there are any open source compilers out there to
    > > translate the C++/Java/C#-like object model to C. Thanks,

    >
    > An early C++ "compiler" perhaps?
    >
    > As I understand it, C++ was initially precompiled to C source.


    yep cfront did it (the original compiler for AT&T). I think comeau c++
    compiler still does that: from C++ sources it generates C code
    http://www.comeaucomputing.com/.
    ppi, Jan 31, 2008
    #4
  5. user923005 Guest

    user923005, Jan 31, 2008
    #5
  6. :

    > I was wondering if there are any open source compilers out there to
    > translate the C++/Java/C#-like object model to C. Thanks,
    >
    > David



    Hidden pointers is what OO is all about for the most part.

    The following in C++:


    class Circle {
    public:

    double radius;

    virtual double GetArea(void)
    {
    3.14 * radius * radius;
    }

    };



    is implemented as:



    typedef struct VTable_Circle {
    double (*GetArea)(Circle*);
    } VTable_Circle;

    typedef struct Circle {
    VTable_Circle const *vtable;

    double radius;
    } Circle;

    double GetArea(Circle *const this)
    {
    return 3.14 * this->radius * this->radius;
    }

    VTable_Circle vtable_circle = { GetArea };

    void ConstructCircle(Circle *const p)
    {
    p->vtable = vtable_circle;
    }


    --
    Tomás Ó hÉilidhe
    Tomás Ó hÉilidhe, Jan 31, 2008
    #6
  7. wrote:
    >I was wondering if there are any open source compilers out there to
    >translate the C++/Java/C#-like object model to C. Thanks,


    Check the Portable Object Compiler for an Objective-C to C translator:

    http://users.pandora.be/stes/compiler.html


    Roberto Waltman

    [ Please reply to the group,
    return address is invalid ]
    Roberto Waltman, Jan 31, 2008
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Dylan Phillips
    Replies:
    0
    Views:
    362
    Dylan Phillips
    Nov 13, 2003
  2. Curt_C [MVP]
    Replies:
    1
    Views:
    415
    Curt_C [MVP]
    Jul 7, 2004
  3. J

    translating in asp.net

    J, Nov 19, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    339
    Scott Allen
    Nov 20, 2004
  4. Jonathan Mcdougall
    Replies:
    2
    Views:
    481
    Kaz Kylheku
    Nov 3, 2005
  5. BillJosephson
    Replies:
    148
    Views:
    2,595
    peter koch
    Jan 27, 2007
Loading...

Share This Page