Re: [PATCH] Various pages: SYNOPSIS: Use VLA syntax in function parameters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/12/22 13:34, Alejandro Colomar wrote:
struct s {
     int a;
};

struct t {
     struct s s;
     int a;
};

void f(void)
{
     struct t x = {
         .a = 1,
         .s = {
             .a = ((struct s) {.a = 1}).a,
         },
     };
}

From here, a demonstration of what I understood from Martin's email is that there's also an idea of allowing the following:


struct s {
    int a;
    int b;
};

struct t {
    struct s s;
    int a;
    int b;
};

void f(void)
{
    struct t x = {
        .a = 1,
        .s = {
            // In the following line, .b=.a is assigning 2
            .a = ((struct s) {.a = 2, .b = .a}).b,
            // The previous line assigned 2, since the compound had 2 in .b
        },
        // In the following line, .b=.a is assigning 1
        .b = .a,
    };
}

--
<http://www.alejandro-colomar.es/>

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux