小编hua*_*xin的帖子

结构内部的联合 - 如何做指定的初始化程序?

我已经在union初始化中读取了struct,但它没有解决我的问题

在我的遗留代码中,我有大量的struct-with-union

typedef struct st 
{
    union
    {
        struct
        {
            uint8    sign ;
            uint8    cells;    
        }s;
        int    data;
    }u;
    int   extra;
} st;
Run Code Online (Sandbox Code Playgroud)

在C下,编译如下:

static const st someval = {
    .sign = 0, .cells ={ 0 },  
    .cells = { 11 }
};
Run Code Online (Sandbox Code Playgroud)

有没有办法最小化更改编译方法(或代码),使其在g ++下编译?

c++ struct

2
推荐指数
1
解决办法
179
查看次数

标签 统计

c++ ×1

struct ×1