Re: Please support coo.h

2010-06-11 Thread Paolo Bonzini
On 06/11/2010 10:15 AM, yuanbin wrote: gcc initial the first member of union now, This is not the C standard also. I just want gcc initial the last member of union with some switch. Why do you want the last one? Is there a compiler that does that (e.g. MSVC++)? If yes, it can be toggled by -

Re: Please support coo.h

2010-06-11 Thread yuanbin
I am familiar with C++, Do not recommend C++ to me. gcc initial the first member of union now, This is not the C standard also. I just want gcc initial the last member of union with some switch. 2010/6/11 Magnus Fromreide : > On Fri, 2010-06-11 at 08:44 +0800, yuanbin wrote: >> typedef struct CBa

Re: Please support coo.h

2010-06-10 Thread Ian Lance Taylor
yuanbin writes: > typedef struct CBase { int i; } CBase; > typedef struct CT1 { EXTENDS(CBase) ... } CT1; > typedef struct CT2 { EXTENDS(CT1) ... } CT2; > ... > typedef struct CTN { EXTENDS(CTN_1) ... } CTN; > CTN t; > t.i=1; //need not t.CTN_1CT2.CT1.CBase.i ---complex > CBase* p=&t.CBase; /

Re: Please support coo.h

2010-06-10 Thread Magnus Fromreide
On Fri, 2010-06-11 at 08:44 +0800, yuanbin wrote: > typedef struct CBase { int i; } CBase; > typedef struct CT1 { EXTENDS(CBase) ... } CT1; > typedef struct CT2 { EXTENDS(CT1) ... } CT2; > ... > typedef struct CTN { EXTENDS(CTN_1) ... } CTN; > CTN t; > t.i=1; //need not t.CTN_1CT2.CT1.CBase.i -

Re: Please support coo.h

2010-06-10 Thread yuanbin
typedef struct CBase { int i; } CBase; typedef struct CT1 { EXTENDS(CBase) ... } CT1; typedef struct CT2 { EXTENDS(CT1) ... } CT2; ... typedef struct CTN { EXTENDS(CTN_1) ... } CTN; CTN t; t.i=1; //need not t.CTN_1CT2.CT1.CBase.i ---complex CBase* p=&t.CBase; //need not t.CTN_1CT2.CT1.CBase

Re: Please support coo.h

2010-06-10 Thread Dave Korn
On 10/06/2010 18:07, yuanbin wrote: > This compiler's extension is valuable No, it isn't very valuable, sorry to be blunt. I think you are following a really wrong path here. You are trying to implement a C++-alike object-oriented system in C. That makes sense as far as it goes, but if you fi

Re: Please support coo.h

2010-06-10 Thread yuanbin
This compiler's extension is valuable 2010/6/10 Wojciech Meyer : > On Thu, Jun 10, 2010 at 2:10 PM, yuanbin wrote: >> initialization of global variable? > > No, just define a macro. > >> >> >> 2010/6/10 Andreas Schwab : >>> yuanbin writes: >>> but i want default format: CThis t={0, 1,

Re: Please support coo.h

2010-06-10 Thread Wojciech Meyer
On Thu, Jun 10, 2010 at 2:10 PM, yuanbin wrote: > initialization of global variable? No, just define a macro. > > > 2010/6/10 Andreas Schwab : >> yuanbin writes: >> >>> but i want default format: >>> CThis t={0, 1, 1}; //simple >> >> Define a suitable constructor. > Wojciech

Re: Please support coo.h

2010-06-10 Thread Andreas Schwab
yuanbin writes: > but i want default format: > CThis t={0, 1, 1}; //simple Define a suitable constructor. Andreas. -- Andreas Schwab, sch...@redhat.com GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84 5EC7 45C6 250E 6F00 984E "And now for something completely different."

Re: Please support coo.h

2010-06-10 Thread yuanbin
initialization of global variable? 2010/6/10 Andreas Schwab : > yuanbin writes: > >> but i want default format: >> CThis t={0, 1, 1}; //simple > > Define a suitable constructor. > > Andreas. > > -- > Andreas Schwab, sch...@redhat.com > GPG Key fingerprint = D4E8 DBE3 3813 BB5D FA84  5EC7 45C6 25

Re: Please support coo.h

2010-06-10 Thread yuanbin
-- initialization of the union: union { int i; float f; } t={1.5}; //t.f because of EXTENDS2 in coo.h, compiler needs to initialze last member of union. #include typedef struct VBase {} VBase; typedef struct CBase { VT(VBase) int i; } CBase; typedef struct VThi

Re: Please support coo.h

2010-06-10 Thread Paolo Bonzini
On 06/10/2010 10:57 AM, yuanbin wrote: initialization of the enum: you mean union. enum { int i; float f; } t={1.5}; //t.f The above makes no sense, what if you have int and char? You have to say union { ... } t = { .f = 1.5 }; and that already works in G