小编use*_*800的帖子

如何在C中的头文件中初始化结构的结构?

我试图将一些旧的代码从一个20岁的DOS系统移植到GNU Linux系统.在他们的几个头文件中(包含在整个地方),它们具有它们声明和初始化的结构体的结构.当我编写遗留代码的方式编译时,我收到警告.有关如何使其保持在同一个头文件中的任何提示?

以下是我对其所做的简化示例.

struct A
{

    struct B  temp1;
    struct C  temp2;
};

struct B
{

    int temp3;
    int temp4; 
    int temp5;
};

struct C
{

    int temp6;
    int temp7;
    int temp8;
};


//These are the variables in how they are related to the initialization below

//struct A test_one = {{temp3,temp4,temp5},{temp6,temp7,temp8}};

struct A test_one = {{1,2,3},{4,5,6}};
Run Code Online (Sandbox Code Playgroud)

c struct gnu initialization header

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

标签 统计

c ×1

gnu ×1

header ×1

initialization ×1

struct ×1