Please create an account to participate in the Slashdot moderation system

 



Forgot your password?
typodupeerror
Programming Microsoft Linux

The Linux Kernel Looks To 'Bite the Bullet' In Enabling Microsoft C Extensions (phoronix.com) 42

Linux kernel developers are moving toward enabling Microsoft C Extensions (-fms-extensions) by default in Linux 6.19, with Linus Torvalds signaling no objection. While some dislike relying on Microsoft-style behavior, the patches in kbuild-next suggest the project is ready to "bite the bullet" and adopt the extensions system-wide. Phoronix reports: Rasmus Villemoes argued with Kbuild: enable -fms-extensions that would allow for "prettier code" and others have noted in the past the potential for saving stack space and all around being beneficial in being able to leverage the Microsoft C behavior: "Once in a while, it turns out that enabling -fms-extensions could allow some slightly prettier code. But every time it has come up, the code that had to be used instead has been deemed 'not too awful' and not worth introducing another compiler flag for. That's probably true for each individual case, but then it's somewhat of a chicken/egg situation. If we just 'bite the bullet' as Linus says and enable it once and for all, it is available whenever a use case turns up, and no individual case has to justify it..."

The second patch is kbuild: Add '-fms-extensions' to areas with dedicated CFLAGS to ensure -fms-extensions is passed for the CPU architectures that rely on their own CFLAGS being set rather than the main KBUILD_CFLAGS. Linus Torvalds chimed in on the prior mailing list discussion and doesn't appear to be against enabling -fms-extensions beginning with the Linux 6.19 kernel.

The Linux Kernel Looks To 'Bite the Bullet' In Enabling Microsoft C Extensions

Comments Filter:
  • by 93 Escort Wagon ( 326346 ) on Monday November 10, 2025 @09:45PM (#65787158)

    -embrace-extend-extinguish

    • by OrangeTide ( 124937 ) on Monday November 10, 2025 @11:26PM (#65787240) Homepage Journal

      It's a GNU-flavored version of those MS extensions, originally they added a subset of what MS does in order to let gcc use data structures in MS's headers and have somewhat source compatible builds (I think this was roughly around the time Cygwin popped up, but I'm not sure).

      A fair number of professional teams enabled those extensions for non-Windows code because they like some of the tricks available with the extensions and use it in their proprietary or open source code. It's a trend that has finally spread to the Linux kernel. I think this was really only possible as some of the kernel grognards retired or were otherwise not around to put up a fight and generally maintain the inertia force on LKML. Torvalds himself isn't quite as grumpy as people think and is generally pretty pragmatic and can be influenced by consensus and reasonable arguments.

      • Torvalds himself isn't quite as grumpy as people think

        Or maybe he has more clue about those "microsoft extensions" actually do.

        • Hopefully anyone with GNU info installed knows what it does.

          There are two things it does, one of which helps parse those pesky Windows headers when using C++. Of course that doesn't apply at all to Linux as it is not Windows and doesn't use C++ in the kernel. The other is unnamed struct/union members, which is standard in modern C but the Linux kernel isn't quite willing to accept everything in C11, so picking up some extensions that are accepted is the compromise.

      • by PPH ( 736903 )

        in order to let gcc use data structures in MS's headers and have somewhat source compatible builds

        This is what I fear. I'm just not certain whose source will be "leaking" into whose kernel. Or why, if Linux devs (Linus) have decided up to this point _not_ to adopt a standard C construct, it is now considered to be a good idea.

        Are we developing Linux using the Cut-N-Paste culture of Stack Overflow?

    • Windows OT uses OTFS by extension.
    • Re: (Score:1, Insightful)

      by scalptalc ( 6477834 )
      What's plus 5 funny here is if you're old enough to remember the childish arrogance of the crowd in the bazaar. It's a long game, kiddos, especially if you make everything your enemy.
  • by Anonymous Coward

    I really would like to see that to use some of those DLL extensions I still have laying around.

    • by Locutus ( 9039 )
      What goes out to 4Chan: It's all about being able to use ActiveX in the Linux kernel so that WSL will have better security and reliability.

      LoB
  • The kernel enables also `rm -rf /` as root, yet you might choose not to use it.
  • by tender-matser ( 938909 ) on Tuesday November 11, 2025 @01:45AM (#65787310)

    The actual feature enabled by the "-fms-extensions" option in gcc is anonymous member structs and unions, which had first appeared in plan9 and was invented by the same people who created the C language in the first place.

    • by tender-matser ( 938909 ) on Tuesday November 11, 2025 @02:12AM (#65787318)

      That extension basically lets you to extend C structs like in C++, but allows you to add new members *both* at the start and at the end of the base struct:

      struct foo {
          int m;
      };
      struct bar {
          int before;
          struct foo;
          int after;
      };
      int main() {
          struct bar b; b.m = 33;
      }

      • by nyet ( 19118 )

        IMO this is a good thing, not a bad one.

      • by tlhIngan ( 30335 )

        Or rather, unnamed unions:

        struct my_struct {
        int a;
        union {
        int b;
        double c;
        void* d;
        };
        int e;
        } foo, *bar;

        You can then reference t as foo,a, foo.b, foo.c, foo.d, and foo.e.

        Without it the union must be named:

        struct my_struct {

    • by ebcdic ( 39948 )

      Example:

      struct object {
            enum object_type type;
            union {
                    struct { struct object *car; struct object *cdr; };
                    double number;
            };
      };

      struct object *foo;

      Now we can say foo->cdr instead of (say) foo->value.cons.cdr.

      • by Anonymous Coward
        Those are anonymous unions and structs. The C Standard already supports them. That's not what's being referred to.
        • by ebcdic ( 39948 )

          Oops yes, in trying to give a realistic example I forgot to use the actual feature in question. The extension is that the internal struct or union may have a tag, and indeed may be declared elsewhere. So it could be "union {struct cons; double number;}".

  • I would have thought there are advantages to keeping the Linux kernel as a 'strictly conforming application' using only the standard C language features.

  • by Rene S. Hollan ( 1943 ) on Tuesday November 11, 2025 @10:20AM (#65787860)

    Blech.

    While I can appreciate the motivation, it is always best to stick to widely recognized standards as far as programming languages go.

  • Explain the potential security implications, assuming there are any?

    • by Locutus ( 9039 )
      Uh uh. I know what you're thinking. You're thinking 'Does this inject a security flaw or hazard?' Now to tell you the truth, I've forgotten myself in all decades just how insecure Microsoft software is. But being this is a Linux kernel, the most powerful kernel in the world, and will blow Microsoft's kernel clean off the rack, you've gotta ask yourself a question: 'Do I feel lucky?' Well, do ya?

      LoB
  • As a step toward application portability between Microsoft apps and Linux systems, maybe. But that seems to be more at the library level. But who out there is suggesting that we need to splice Microsoft stuff (drivers, etc.) directly into the Linux kernel?

    On the other hand, it could help in porting systemd to Windows.

    • Re: (Score:3, Insightful)

      by caseih ( 160668 )

      Application portability doesn't enter into it, nor does this have anything to do with code at a binary or library level. Nothing to do with Windows drivers! Not sure why you brought that up.

      This is the Linux kernel we're talking about. This extension allows slightly cleaner, easier-to-read syntax in certain circumstances. As I understand it, it's syntactic sugar that brings a bit of C++'s ability to cleanly extend structs to C. This is clearly shown by some insightful comments above.

      Nice dig at systemd,

    • What in the fucking hell are you blathering on about?

      This is about a language extension that adds great quality-of-life to struct declarations.
      If you think a language barrier is what holds systemd back from $any_non_linux_os, then you are so fucking out of your depth here that I assume you must have drowned hours ago, and the noise is just now reaching us.

You are false data.

Working...