473,396 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Unnamed union

I know it is possible to use unnamed struct or unions inside of struct like
in the following example:

typedef struct {
union {
int moin;
char carl;
};
int bon;
} dastruct;

int main(int argc, char * argv[])
{
dastruct thestruct;

thestruct.carl = 'a';
thestruct.bon=6;
...
Now I have a compiler which does not allow me to acces moin or carl unless I
give the union a name, like here:

typedef struct {
union {
int moin;
char carl;
} x;
int bon;
} dastruct;
int main(int argc, char * argv[])
{
dastruct thestruct;

thestruct.x.carl = 'a';
thestruct.bon=6;
....
What I wonder is, wheter unnamed struct and unions are a feature of newer C
standard (C99)?

Kind regards,
Frank

Nov 13 '05 #1
2 9501
Frank Roland wrote:

I know it is possible to use unnamed struct or unions inside of struct like
in the following example:

typedef struct {
union {
int moin;
char carl;
};
int bon;
} dastruct;
I know that the Earth is flat, that the Moon is made of
green cheese, and that the stuff advertised in all those
E-mails really will make my member grow larger.
What I wonder is, wheter unnamed struct and unions are a feature of newer C
standard (C99)?


No, and this is not a change: No C Standard has permitted
nameless elements in structs, with the exception of a special
case involving bit-fields. Various compilers have supported
this as an extension to the C language, but it has always
been an extension.

--
Er*********@sun.com
Nov 13 '05 #2
Greetings.

In article <bm*************@news.t-online.com>, Frank Roland wrote:
What I wonder is, wheter unnamed struct and unions are a feature of newer
C standard (C99)?


I asked this back in message <39***************@ontrack.com> -- the answer
is no, C99 does not support anonymous unions. Pity, as they are supported
in C++, and I actually use them from time to time.

Regards,
Tristan

--
_
_V.-o Tristan Miller [en,(fr,de,ia)] >< Space is limited
/ |`-' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-= <> In a haiku, so it's hard
(7_\\ http://www.nothingisreal.com/ >< To finish what you
Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Anthony | last post by:
Hello, I have been reading up on unnamed namespaces in the context of hiding classes as mentionned by the GOF Facade pattern description. I was hoping someone could shed some light on this. I...
3
by: Sandy | last post by:
Hi, I have two files as folllows file1.cpp #include<iostream> using namespace std; namespace { void show(); void fun() { cout<<"fun called\n"; } }
9
by: Ivan Mascovich | last post by:
Previous posts (and compilers) confirm that class X { friend void Y() ; } ; does not match namespace
7
by: Roman Mashak | last post by:
Hello, All! I'm trying to compile some driver for MIPS target, and get errors. I assumed these may be related to C language. tigon3.h:2225: unnamed fields of type other than struct or union...
12
by: Jalapeno | last post by:
I've a CICS program that uses BMS maps. Our wysiwyg map editor produces it's source in COBOL so I am manually creating C unions to match the COBOL output. Can I convert the FILLER statements to...
9
by: Tom Plunket | last post by:
The project I'm currently on makes heavy use of unnamed structures to represent an "object hierarchy" of a sort. E.g. struct BaseObject { int aMember; int anotherMember; // etc.
18
by: Ehud Shapira | last post by:
Is it possible to have a declaration of a struct pointer initialized to an unnamed struct? (I'm only concerned with static/global variables, if it matters.) I'm trying to do something like: ...
3
by: CrazyJohn | last post by:
Hi guys, This is my first time posting question here, if I break any rules, please kindly point out. And I'm really glad to be a part of this community. Here is my question, Our lecturer...
1
by: manjuns | last post by:
I have two tables Table A with columns name, eid Table B with columns text, eida select name, eid tableA where eid=1 union select name, eida tableB where eida=1
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.