34
submitted 3 months ago by CodiUnicorn@programming.dev to c/linux@lemmy.ml
top 14 comments
sorted by: hot top controversial new old
[-] mina86@lemmy.wtf 47 points 3 months ago

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
[-] Obin@feddit.org 20 points 3 months ago* (last edited 3 months ago)

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)

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

[-] MinekPo1@lemmygrad.ml 3 points 3 months ago* (last edited 3 months ago)

"ANSI C" by Kernighan and Ritchie disagrees , including that syntax (note : retranslation from Polish as that's the language my copy is in) :

A8.3

[...]

struct-union-specifier:
, union-struct identifier ₒₚₜ { compound-declaration-list }
, union-struct identifier

[...]

Specifiers of structures or unions with [a compound declaration] list, but with no label [identifier], creates a unique type; it may only be referred to in the declaration in which it is part.

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

Yes, but I was talking about field name, not struct tag. And up to C99 my comment was correct.

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

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.

[-] ZkhqrD5o@lemmy.world 14 points 3 months ago

If I understood correctly, it's free software anyway, so why the discussion?

[-] vort3@lemmy.ml 17 points 3 months ago* (last edited 3 months ago)

Because they wanted drama and clickbaity headline.

[-] MyNameIsRichard@lemmy.ml 9 points 3 months ago
[-] fubarx@lemmy.world 5 points 3 months ago
[-] PragmaticOne@lemmy.world 1 points 3 months ago

This is a non story but people want to hate on MS so will grasp anything they can to try and make a thing out of it.

this post was submitted on 10 Nov 2025
34 points (75.8% liked)

Linux

62524 readers
366 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