C error: dereferencing pointer to incomplete type, struct
C error: dereferencing pointer to incomplete type, struct
我知道这个问题被问了很多次,但我似乎无法link解决我的问题。
我的问题与填写结构网有关
这是我的错误代码
src\fpu.c:17:7: error: dereferencing pointer to incomplete type
cpu->instr.fpu.control = 0x37F;
^
这是函数中的错误代码
void fpuInit(struct emu_cpu *cpu) {
cpu->instr.fpu.control = 0x37F;
cpu->instr.fpu.status = 0;
cpu->instr.fpu.tag = 0xFFFF;
cpu->instr.fpu.lastDataPointer = 0;
cpu->instr.fpu.lastDataSeg = 0;
cpu->instr.fpu.lastIP = 0;
cpu->instr.fpu.lastIPseg = 0;
cpu->instr.fpu.opcode = 0;
}
这是 struct web 的样子
cpu
struct emu_cpu
{
struct emu *emu;
struct emu_memory *mem;
uint32_t debugflags;
uint32_t eip;
uint32_t eflags;
uint32_t reg[8];
uint16_t *reg16[8];
uint8_t *reg8[8];
struct emu_instruction instr;
struct emu_cpu_instruction_info *cpu_instr_info;
uint32_t last_fpu_instr[2];
char *instr_string;
bool repeat_current_instr;
struct emu_track_and_source *tracking;
};
说明
struct emu_instruction
{
uint16_t prefixes;
uint8_t opcode;
uint8_t is_fpu : 1;
union
{
struct emu_cpu_instruction cpu;
struct emu_fpu_instruction fpu;
};
struct
{
struct emu_tracking_info init;
struct emu_tracking_info need;
} track;
struct
{
uint8_t has_cond_pos : 1;
uint32_t norm_pos;
uint32_t cond_pos;
} source;
};
fpu 结构
union FpuMmxRegister {
long double fp;
unsigned char b[10]; //only use 8 of these for mmx
unsigned short s[4];
unsigned int i[2];
unsigned long long ll;
};
struct emu_fpu_instruction
{
uint16_t prefixes;
uint8_t fpu_opcode;
//uint8_t fpu_modrm;
struct /* mod r/m data */
{
union
{
uint8_t mod : 2;
uint8_t x : 2;
};
union
{
uint8_t reg1 : 3;
uint8_t opcode : 3;
uint8_t sreg3 : 3;
uint8_t y : 3;
};
union
{
uint8_t reg : 3;
uint8_t reg2 : 3;
uint8_t rm : 3;
uint8_t z : 3;
};
struct
{
uint8_t scale : 2;
uint8_t index : 3;
uint8_t base : 3;
} sib;
union
{
uint8_t s8;
uint16_t s16;
uint32_t s32;
} disp;
uint32_t ea;
} fpu_modrm;
//uint32_t ea;
uint16_t control;
uint16_t status;
uint16_t tag;
uint32_t lastIP;
uint32_t lastIPseg;
uint32_t lastDataPointer;
uint32_t lastDataSeg;
uint16_t opcode;
uint32_t last_instr;
union FpuMmxRegister r[8];
};
告诉我我做错了什么谢谢
只是让你知道他们在那个起始函数中都是错误的
src\fpu.c:17:7: error: dereferencing pointer to incomplete type
cpu->instr.fpu.control = 0x37F;
^
src\fpu.c:18:7: error: dereferencing pointer to incomplete type
cpu->instr.fpu.status = 0;
^
src\fpu.c:19:7: error: dereferencing pointer to incomplete type
cpu->instr.fpu.tag = 0xFFFF;
^
src\fpu.c:20:7: error: dereferencing pointer to incomplete type
cpu->instr.fpu.lastDataPointer = 0;
^
src\fpu.c:21:7: error: dereferencing pointer to incomplete type
cpu->instr.fpu.lastDataSeg = 0;
^
src\fpu.c:22:7: error: dereferencing pointer to incomplete type
cpu->instr.fpu.lastIP = 0;
^
src\fpu.c:23:7: error: dereferencing pointer to incomplete type
cpu->instr.fpu.lastIPseg = 0;
^
src\fpu.c:24:7: error: dereferencing pointer to incomplete type
cpu->instr.fpu.opcode = 0;
^
您对 struct emu_cpu
的定义在函数 fpuInit
的定义点不可见。因此,fpuInit
定义中对 struct emu_cpu
的所有引用都被视为新的不完整类型的前向声明。
如果您的 struct emu_cpu
是在头文件中定义的,请确保它包含在定义 fpuInit
的文件中。
匿名联合只允许在结构树的端:
在
a->b.c.d =
d 可以是匿名(没有名字)结构或联合,
b和c不能,需要有名字。
参考:**Are "anonymous structs" standard? And, really, what *are* they? **
我知道这个问题被问了很多次,但我似乎无法link解决我的问题。
我的问题与填写结构网有关
这是我的错误代码
src\fpu.c:17:7: error: dereferencing pointer to incomplete type
cpu->instr.fpu.control = 0x37F;
^
这是函数中的错误代码
void fpuInit(struct emu_cpu *cpu) {
cpu->instr.fpu.control = 0x37F;
cpu->instr.fpu.status = 0;
cpu->instr.fpu.tag = 0xFFFF;
cpu->instr.fpu.lastDataPointer = 0;
cpu->instr.fpu.lastDataSeg = 0;
cpu->instr.fpu.lastIP = 0;
cpu->instr.fpu.lastIPseg = 0;
cpu->instr.fpu.opcode = 0;
}
这是 struct web 的样子
cpu
struct emu_cpu
{
struct emu *emu;
struct emu_memory *mem;
uint32_t debugflags;
uint32_t eip;
uint32_t eflags;
uint32_t reg[8];
uint16_t *reg16[8];
uint8_t *reg8[8];
struct emu_instruction instr;
struct emu_cpu_instruction_info *cpu_instr_info;
uint32_t last_fpu_instr[2];
char *instr_string;
bool repeat_current_instr;
struct emu_track_and_source *tracking;
};
说明
struct emu_instruction
{
uint16_t prefixes;
uint8_t opcode;
uint8_t is_fpu : 1;
union
{
struct emu_cpu_instruction cpu;
struct emu_fpu_instruction fpu;
};
struct
{
struct emu_tracking_info init;
struct emu_tracking_info need;
} track;
struct
{
uint8_t has_cond_pos : 1;
uint32_t norm_pos;
uint32_t cond_pos;
} source;
};
fpu 结构
union FpuMmxRegister {
long double fp;
unsigned char b[10]; //only use 8 of these for mmx
unsigned short s[4];
unsigned int i[2];
unsigned long long ll;
};
struct emu_fpu_instruction
{
uint16_t prefixes;
uint8_t fpu_opcode;
//uint8_t fpu_modrm;
struct /* mod r/m data */
{
union
{
uint8_t mod : 2;
uint8_t x : 2;
};
union
{
uint8_t reg1 : 3;
uint8_t opcode : 3;
uint8_t sreg3 : 3;
uint8_t y : 3;
};
union
{
uint8_t reg : 3;
uint8_t reg2 : 3;
uint8_t rm : 3;
uint8_t z : 3;
};
struct
{
uint8_t scale : 2;
uint8_t index : 3;
uint8_t base : 3;
} sib;
union
{
uint8_t s8;
uint16_t s16;
uint32_t s32;
} disp;
uint32_t ea;
} fpu_modrm;
//uint32_t ea;
uint16_t control;
uint16_t status;
uint16_t tag;
uint32_t lastIP;
uint32_t lastIPseg;
uint32_t lastDataPointer;
uint32_t lastDataSeg;
uint16_t opcode;
uint32_t last_instr;
union FpuMmxRegister r[8];
};
告诉我我做错了什么谢谢
只是让你知道他们在那个起始函数中都是错误的
src\fpu.c:17:7: error: dereferencing pointer to incomplete type
cpu->instr.fpu.control = 0x37F;
^
src\fpu.c:18:7: error: dereferencing pointer to incomplete type
cpu->instr.fpu.status = 0;
^
src\fpu.c:19:7: error: dereferencing pointer to incomplete type
cpu->instr.fpu.tag = 0xFFFF;
^
src\fpu.c:20:7: error: dereferencing pointer to incomplete type
cpu->instr.fpu.lastDataPointer = 0;
^
src\fpu.c:21:7: error: dereferencing pointer to incomplete type
cpu->instr.fpu.lastDataSeg = 0;
^
src\fpu.c:22:7: error: dereferencing pointer to incomplete type
cpu->instr.fpu.lastIP = 0;
^
src\fpu.c:23:7: error: dereferencing pointer to incomplete type
cpu->instr.fpu.lastIPseg = 0;
^
src\fpu.c:24:7: error: dereferencing pointer to incomplete type
cpu->instr.fpu.opcode = 0;
^
您对 struct emu_cpu
的定义在函数 fpuInit
的定义点不可见。因此,fpuInit
定义中对 struct emu_cpu
的所有引用都被视为新的不完整类型的前向声明。
如果您的 struct emu_cpu
是在头文件中定义的,请确保它包含在定义 fpuInit
的文件中。
匿名联合只允许在结构树的端:
在
a->b.c.d =
d 可以是匿名(没有名字)结构或联合,
b和c不能,需要有名字。
参考:**Are "anonymous structs" standard? And, really, what *are* they? **