This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Please support coo.h


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 <magfr@lysator.liu.se>:
> 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_1....CT2.CT1.CBase.i ---complex
>> CBase* p=&t.CBase; //need not t.CTN_1....CT2.CT1.CBase, need not
>> (CBase*)&t ---not safe
>
> struct CBase { int i; };
> struct CT1 : CBase { ... };
> struct CT2 : CT1 { ... };
> struct CTN : CTN_1 { ... };
> CTN t;
>
> t.i = 1; // assumes this is in function scope
> CBase* p = &t; // Even simpler than your proposal and still safe.
>
> Yep, this is valid C++. I think Dave is right, you really want C++.
>
> /MF
>
>>
>> 2010/6/11 Dave Korn <dave.korn.cygwin@gmail.com>:
>> > 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
>> > find yourself having to propose modifying the C compiler in a direction that
>> > basically makes it speak C++, you might as well just use C++ in the first
>> > place. ?You want the compiler to automatically choose one of several different
>> > ways to initialise a union according to the data type of the argument you use
>> > to initialise it with; basically, that means you want overloaded constructors.
>> > ?So you should just use C++, which already is C with overloaded constructors.
>> > ?And it also already has all the other features that you'll discover you need
>> > in the compiler as you carry along this path.
>> >
>> > ?By the time you get to the end of your journey, "coo.h" will be an empty
>> > file and all the functionality will have been added to the C compiler until it
>> > turns into a C++ compiler. ?I think you need to choose a different plan.
>> >
>> > ? ?cheers,
>> > ? ? ?DaveK
>> >
>> >
>
>
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]