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.

  • entwine@programming.dev
    link
    fedilink
    arrow-up
    3
    ·
    1 day ago

    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.