A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2019-April/157130.html below:

[Python-Dev] PEP 7: Adding anonymous union

[Python-Dev] PEP 7: Adding anonymous union / struct [Python-Dev] PEP 7: Adding anonymous union / structInada Naoki songofacandy at gmail.com
Wed Apr 17 07:10:44 EDT 2019
Hi, all.

PEP 7 includes some C99 features.
I propose to add include anonymous union and struct to the list.
https://www.geeksforgeeks.org/g-fact-38-anonymous-union-and-structure/

Anonymous union and struct are C11 feature, not C99.
But gcc and MSVC supported it as language extension from before C11.

Anonymous union is useful when all union members have different names.
Especially, when we need to add dummy member only for padding / alignment,
union name looks too verbose:

... # in some struct
union {
    struct {
       int member1;
       int member2;
    } s;
    long double _dummy;  // for largest alignment.
} u;
...
x.u.s.member1 = 42;

vs

...
union {
    struct {
       int member1;
       int member2;
    };
    long double _dummy;  // for largest alignment.
};
...
x.member1 = 42;


Does anyone know compiler which can be use to compile Python but
doesn't support anonymous union / struct?

Regards,
-- 
Inada Naoki  <songofacandy at gmail.com>
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4