this post was submitted on 10 Nov 2025
35 points (75.4% liked)

Linux

63552 readers
478 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 6 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] mina86@lemmy.wtf 46 points 3 months ago (1 children)

This is hardly newsworthy. If the extensions were called ‘Jabberwocky C Extennsions’ no one would have cared. The extension allows for tagged unnamed structs inside of a struct, e.g.:

struct inner { /* ... */ };
struct outer {
    int value;
    struct inner;
};
[–] tabular@lemmy.world 5 points 3 months ago (2 children)
[–] Obin@feddit.org 20 points 3 months ago* (last edited 3 months ago) (1 children)

You mean 'unnamed' is what's confusing you?

Normally you can do anonymous struct/union members or struct struct/union members that are tagged structs but not anonymous.

I.e. in standard C you'd have to do either:

struct foo { int baz; };
struct bar { struct foo foo; };
...
struct bar data;
data.foo.baz = 0;

or:

struct bar { struct {  int baz; } foo; };
...
struct bar data;
data.baz = 0;

but to do the following, you'd need the extension:

struct foo { int baz; };
struct bar { struct foo; };
...
struct bar data;
data.baz = 0;
[–] mina86@lemmy.wtf 8 points 3 months ago* (last edited 3 months ago) (1 children)

~~Minor correction: Unnamed structs and unions (so your second example) are not part of C. They are GNU extensions.~~

[–] Obin@feddit.org 3 points 3 months ago* (last edited 3 months ago) (1 children)

Unless I'm misunderstanding something, I'm pretty sure they've been standardized in C11. Also mentioned here.

[–] mina86@lemmy.wtf 1 points 3 months ago

You appear to be correct.

[–] mina86@lemmy.wtf 13 points 3 months ago* (last edited 3 months ago)

Tag is what goes after the struct keyword to allow referring to the struct type. Structs don’t have to have a tag. Name is what field are called. Adapting Obin’s example:

struct foo { int baz; };
struct bar { struct foo qux; };
struct bar data;
data.qux.baz = 0;

foo and bar are tags for struct foo and struct bar types respectively; baz and qux are field names; and data is a variable name.