By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,376 Members | 1,557 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,376 IT Pros & Developers. It's quick & easy.

union ( members with same name )

P: n/a
Is possible I have a union with its members having the same name as below ?

union {
MyType myVar;
MyType myVar;
MyType myVar;
OtherType otherVar;

} MyUnion;
I am using "gcc" but it don't compile. do I need any compile option ?

Thank you,

Frederico Faria
Nov 13 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On 4 Jul 2003 15:38:57 -0700, fr********@yahoo.com.br (Frederico
Faria) wrote in comp.lang.c:
Is possible I have a union with its members having the same name as below ?
No. Each one must have a different name.

union {
MyType myVar;
MyType myVar;
MyType myVar;
OtherType otherVar;

} MyUnion;
I am using "gcc" but it don't compile. do I need any compile option ?

Thank you,

Frederico Faria


--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq
Nov 13 '05 #2

P: n/a
fr********@yahoo.com.br (Frederico Faria) wrote (04 Jul 2003) in
news:73*************************@posting.google.co m / comp.lang.c:
Is possible I have a union with its members having the same name
as below ?

union {
MyType myVar;
MyType myVar;
MyType myVar;
OtherType otherVar;

} MyUnion;
I am using "gcc" but it don't compile. do I need any compile
option ?


What do you think such a "union" could mean? If you referred to
MyUnion.myVar, which one do you think it would be? Of course this is
illegal. Even gcc doesn't have a compile option that could make
sense of this hash.

--
Martin Ambuhl
Returning soon to the
Fourth Largest City in America
Nov 13 '05 #3

P: n/a

Frederico Faria <fr********@yahoo.com.br> wrote in message
news:73*************************@posting.google.co m...
Is possible I have a union with its members having the same name as below ?

No it is not. If it were, how could you distinguish one
from another?

union {
MyType myVar;
MyType myVar;
MyType myVar;
OtherType otherVar;

} MyUnion;
I am using "gcc" but it don't compile.
Of course not.
do I need any compile option ?


You need to use the language correctly.

What possible purpose could fulfilling your
above stated desire have?

-Mike

Nov 13 '05 #4

P: n/a
I received a RPC-XDR model to interface with other software.
The XDR model have o type below:

union X721EventInfo
switch (X721EventType eventType) {
case AT_COMMUNICATIONS : X721AlarmInfo alarmInfo;
case AT_QUALITY_OF_SERVICE : X721AlarmInfo alarmInfo;
case AT_PROCESSING_ERROR : X721AlarmInfo alarmInfo;
case AT_EQUIPMENT : X721AlarmInfo alarmInfo;
case ST_INFORMATION : X732ManagementState managementState;
};
I was confuse because it never compile with gcc. Then now, I changed
the X721EventInfo definition to have the members with diferent names.

Thank you,

Faria

"Mike Wahler" <mk******@mkwahler.net> wrote in message news:<be**********@slb9.atl.mindspring.net>...
Frederico Faria <fr********@yahoo.com.br> wrote in message
news:73*************************@posting.google.co m...
Is possible I have a union with its members having the same name as below

?

No it is not. If it were, how could you distinguish one
from another?

union {
MyType myVar;
MyType myVar;
MyType myVar;
OtherType otherVar;

} MyUnion;
I am using "gcc" but it don't compile.


Of course not.
do I need any compile option ?


You need to use the language correctly.

What possible purpose could fulfilling your
above stated desire have?

-Mike

Nov 13 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.