The Linux Kernel Looks to "Bite the Bullet" in Enabling Microsoft C Extensions

phoronix.com

59 points by keyle 5 hours ago


1718627440 - 29 minutes ago

Note that these are not the Microsoft "C Extensions", but the "Microsoft C Extensions" of the GNU Compiler Toolchain. I doubt MSVC supports -fms-extensions.

fuhsnn - 4 hours ago

> though some may feel the wrong way around Microsoft C behavior being permitted

The same extension can be enabled with `-fplan9-extensions`, might be more appealing to some!

netbsdusers - an hour ago

If it's about "prettier code" then I think a number one candidate would be making bitfields more viable for use. It could make driver code much cleaner and safer.

Windows is only targeting little-endian systems which makes life easier (and in any case they trust MSVC to do the right thing) so Windows drivers make much use of them (just look at the driver samples on Microsoft's GitHub page.)

Linux is a little afraid to rely on GCC/Clang doing the right thing and in any case bitfields are underpowered for a system which targets multiple endians. So Linux uses systems of macros instead for dealing with what Windows C uses bitfields. The usual pattern is a system of macros for shifting and masking. This is considerably uglier and easier to make a mess of. It would be a real improvement in quality-of-life if this were not so.

You can also look at Managarm (which benefits from C++ here) for another approach to making this less fraught: https://github.com/managarm/managarm/blob/a698f585e14c0183df...

unwind - 5 hours ago

Huh. I thought the article was vague on what exactly these extensions permit, so I'd thought I'd look up the GNU documentation. Surprisingly, it [1] was rather vague too!

The only concrete example is:

Accept some non-standard constructs used in Microsoft header files.

In C++ code, this allows member names in structures to be similar to previous types declarations.

    typedef int UOW;
    struct ABC {
      UOW UOW;
    };

[1]: https://gcc.gnu.org/onlinedocs/gcc/C-Dialect-Options.html#in...
yinkindog - an hour ago

Extremely tangential: I maintain some of Rasmus's code. I've never met the man. I'd heard that kernel programmers were the "rockstar programmers of rockstar programmers", but I only grok it now.

His code is so clear, clean, concise, commented it feels divine in comparison to the drivel I subject myself to daily.

nurettin - 26 minutes ago

Tinfoil Hat Time: Microsoft is dropping windows and OS development, MS/Linux in the future.

You've heard it here first.

MangoToupe - 2 hours ago

This really speaks more to the inadequacy of C rather than Microsoft.

mrlonglong - 4 hours ago

Microsoft "embrace, extend and takeover" comes to mind here. Caveat emptor.