Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #158402
| From | "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Anonymous unions |
| Date | 2021-01-16 14:08 -0800 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <rtvo50$5cf$1@gioia.aioe.org> (permalink) |
| References | (1 earlier) <rtro0d$19gs$2@gioia.aioe.org> <i1gMH.873535$b5kb.224574@fx15.ams4> <rts4li$cp0$1@dont-email.me> <cae3c3da-9997-4984-9f10-0eff6908ce02n@googlegroups.com> <rtvnut$v2$2@gioia.aioe.org> |
On 1/16/2021 2:05 PM, Chris M. Thomasson wrote:
> On 1/15/2021 6:37 AM, Thiago Adams wrote:
>> On Friday, January 15, 2021 at 10:17:51 AM UTC-3, Bonita Montero wrote:
>>>> They have worked for every compiler I've used for probably 20 years.
>>>> Probably C11 makes them official, if not C99.
>>> Yes, they exist since C11:
>>> https://en.cppreference.com/w/c/language/union#Explanation
>>> But I'm sure the behaviour is implementation-defined if you use them
>>> for aliasing-purposes.
>>
>>
>> Just for curiosity, Microsoft compiler has an extension that
>> injects one struct on another. They are unnamed members.
>>
>> struct point2d { int x,y; };
>> struct point3d { struct point2d; int z; };
>>
>> int main(){
>> struct point3d pt = {.x=1, .y=2 , .z=3};
>> }
>>
>
>
> Interesting. Never tried it out.
I am assuming that the names of the struct members need to be unique? x,
y, z works well here. So would p0, p1, p2, ... as individual component
parts of a point.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Anonymous unions Steve Keller <keller.steve@gmx.de> - 2021-01-15 09:45 +0100
Re: Anonymous unions "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-01-15 01:41 -0800
Re: Anonymous unions Sumireko Usami <usasumi3hu@gmail.com> - 2021-01-15 13:00 +0100
Re: Anonymous unions "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-01-16 14:04 -0800
Re: Anonymous unions Bart <bc@freeuk.com> - 2021-01-15 12:38 +0000
Re: Anonymous unions Bonita Montero <Bonita.Montero@gmail.com> - 2021-01-15 14:18 +0100
Re: Anonymous unions Thiago Adams <thiago.adams@gmail.com> - 2021-01-15 06:37 -0800
Re: Anonymous unions "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-01-16 14:05 -0800
Re: Anonymous unions "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-01-16 14:08 -0800
Re: Anonymous unions Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-01-16 19:04 -0800
Re: Anonymous unions "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-01-16 19:32 -0800
Re: Anonymous unions Tim Rentsch <tr.17687@z991.linuxsc.com> - 2021-01-15 10:10 -0800
Re: Anonymous unions Andrey Tarasevich <andreytarasevich@hotmail.com> - 2021-01-15 19:48 -0800
csiph-web