Coo - C, Object Oriented
http://sourceforge.net/projects/coo/

---------coo.h--------------
#ifndef __COO_H__
#define __COO_H__

typedef struct VTable /*root of virtual table class*/
{
    long offset; /*servers for FREE*/
} VTable;

#define EXTENDS(s) \
    union \
    { \
        s s; \
        s; \
    };
#define VT(v) const v* vt;
#define EXTENDS2(s,v) \
    union \
    { \
        VT(v) \
        s s; \
        s; \
    };
#ifndef offsetof
#define offsetof(s,m) ((long)&((s*)0)->m)
#endif
#define SUPER(s,m,p) ((s*)((char*)(p)-offsetof(s,m)))
#define FREE(p,vt) free((char*)(p)-(vt)->offset)

#endif

----------------------------------
initialization of the enum:
enum {
  int i;
  float f;
} t={1.5}; //t.f
because of EXTENDS2 in coo.h, compiler needs
to initialze last member of enum.

Reply via email to