Linux C MS extensions

Content:

Original link: The Linux Kernel Looks To "Bite The Bullet" In Enabling Microsoft C Extensions / Phoronix.

And if anyone wonder what those MS extensions realle are.

Standard C:

#include 

struct s1
{
    int a;
    int b;
};

struct s2
{
    struct s1 ab;
    int c;
};  

int main()
{
    struct s2 o;
    o.ab.a = 1;
    o.ab.b = 2;
    o.c = 3;
    printf("%d %d %d\n", o.ab.a, o.ab.b, o.c);
    return 0;
}

C with MS extensions:

#include 

struct s1
{
    int a;
    int b;
};

struct s2
{
    struct s1;
    int c;
};  

int main()
{
    struct s2 o;
    o.a = 1;
    o.b = 2;
    o.c = 3;
    printf("%d %d %d\n", o.a, o.b, o.c);
    return 0;
}
Platform Compile Error
Windows gcc ... gcc -fno-ms-extensions ...
*nix gcc -fms-extensions ... gcc ...

Note that these MS extensions are not allowed in C++ and does not make any sense in C++ either:

#include 

struct s1
{
    int a;
    int b;
};

struct s2 : s1
{
    int c;
};  

int main()
{
    struct s2 o;
    o.a = 1;
    o.b = 2;
    o.c = 3;
    printf("%d %d %d\n", o.a, o.b, o.c);
    return 0;
}

Comments: