Two patches queued into the Linux kernel's build system development tree, kbuild-next, would enable the -fms-extensions compiler argument everywhere for allowing GCC and LLVM/Clang to use the Microsoft C Extensions when compiling the Linux kernel. Being in kbuild-next these patches will likely be submitted for the Linux 6.19 kernel merge window next month but remains to be seen if there will be any last minute objections to this change.
The -fms-extensions compiler option honored by the GNU Compiler Collection and LLVM/Clang allow enabling some non-standard C/C++ constructs used within Microsoft header files and honored by the the Microsoft Visual C/C++ compiler. For Linux kernel development purposes, enabling the Microsoft C Extensions would allow including a tagged struct or union anonymously in another struct/union.
The Linux Kernel Looks To "Bite The Bullet" In Enabling Microsoft C Extensions
https://www.phoronix.com/news/Linux-6.19-Patch-Would-MS-Ext
26 Comments
BombOmOm@lemmy.world · 68 pts · 281d
Pedant thought: The thumbnail shows one biting everywhere but the bullet.
mojofrododojo@lemmy.world · 21 pts · 281d
it's time we nibbled the casing and come to terms with bite the bullet, it's just a bad metaphor.
klangcola@reddthat.com · 7 pts · 281d
In Danish and Norwegian the equivalent idiom is to "Swallow a camel" which sounds much funnier xD
mojofrododojo@lemmy.world · 3 pts · 280d
sounds dry lol
DeltaWingDragon@sh.itjust.works · 2 pts · 279d
Time to chew the cartridge?
Truscape@lemmy.blahaj.zone · 27 pts · 281d
Would this cause consequences in terms of the project's independence? Or are these extensions able to be distributed freely?
GreenCrunch@piefed.blahaj.zone · 78 pts · 281d
From what I can see, the GNU Compiler Collection supports this flag, so you can still build it with 100% free software.
Basically, it's just behavior that doesn't align with the C standard, but was introduced by MS. Then, GCC added a compiler flag which makes it behave like that, so that you can build code that requires that behavior.
It doesn't seem to actually be dependent on MS, rather it's named after them because it emulates the way their compiler works. I hope no Linux maintainers would entertain the idea of making it dependent on a non-free compiler.
clif@lemmy.world · 23 pts · 281d
Yep, that tracks. I'm still pissed off about microsoft's non-standard implementation of HTTP 1.1 from however long ago it was that I had to conditionally work around it on the server side. They believe standards don't apply to them and it seems like they're right.
Truscape@lemmy.blahaj.zone · 23 pts · 281d
Ah, that makes sense. Thanks for the explanation! :)
just_another_person@lemmy.world · 17 pts · 281d
The correct answer. It's just using an extension Microsoft happens to have made, and everything still works fine without it.
Valmond@lemmy.world · 2 pts · 281d
int $ = 3;
Compiled with msvc back in the day for example, could be stuff like that. But IDK.
iloveDigit@piefed.social · 21 pts · 281d
Why?
entwine@programming.dev · 69 pts · 281d
I'm sitting around doing IT shit waiting things to download/backup/install/etc and have nothing better to do, so here's an AI-free explanation with code samples:
It's basically just a code style thing. Standard C allows you to declare unnamed structs/unions within other structs/unions. They must be unnamed, so it'd look like this:
Which is fine, but the
-fms-extensionsflag enables you to do the same thing with named structs. For example:without
-fms-extensions, the above will compile, but won't do what you might assume.bandcwill be members of structtest2, nottest. So something like this won't compile:But with the flag, not only does it work, it also lets you do some convenient things like this:
That is, you can reuse an existing struct definition, which gives you a nice little tool to organize your code.
Source: https://gcc.gnu.org/onlinedocs/gcc/Unnamed-Fields.html
ijhoo@lemmy.ml · 8 pts · 281d
If this is so convenient, why wasn't it made a part of a newer C standard?
entwine@programming.dev · 3 pts · 281d
It's not that convenient. I can't even think of a situation where this would be useful for structs, only unions. And in the case of unions, you usually want to keep them as small as possible (or better yet, avoid them altogether).
But besides that, C is a language that tends to prefer minimalism. Using macros, you can accomplish a similar thing already, even if it's not as nice.
iloveDigit@piefed.social · 8 pts · 281d
Nice, thank you
DeltaWingDragon@sh.itjust.works · 1 pts · 279d
What's the point of this? If you have a struct within a struct, you probably want them to nest. The
-fms-extensionswill un-nest them, which is not what you mean.entwine@programming.dev · 1 pts · 279d
You can already do that in standard C like this:
I can't think of any particular reason why you'd want an unnamed struct inside a struct, but you definitely would want to be able to have an unnamed struct inside a union. I suspect the struct-inside-struct thing can become useful in some scenarios involving unions.
DeltaWingDragon@sh.itjust.works · 1 pts · 277d
Does that really have the same results as the example scenario I described? How would you even access the unnamed struct, since it is unnamed?
entwine@programming.dev · 1 pts · 277d
The same way you did, via the name of the member:
my_test.test2.b = 'x';The unnamed struct provides the type for a member named
test2. Doing it this way saves you the trouble of defining the struct externally and giving it a name. It's identical to this, except in this example you can reuse the struct definition:UnityDevice@lemmy.zip · 8 pts · 281d
Basically the extensions are useful sometimes. Note that they have nothing to do with Microsoft other than being invented by them.
HappyFrog@lemmy.blahaj.zone · 6 pts · 281d
Some software require it sadly
deegeese@sopuli.xyz · 5 pts · 281d
Old languages should be able to learn new tricks.
ZILtoid1991@lemmy.world · 2 pts · 281d
The "extend" phase of EEE.
eleijeep@piefed.social · 6 pts · 281d
FooBarrington@lemmy.world · 4 pts · 281d
No? The article literally explains that it's for something else?
DeltaWingDragon@sh.itjust.works · 1 pts · 279d
I sense a fork coming