我真的不明白这里发生了什么.我试图访问.c文件中的结构的成员,但是当我尝试访问struct变量时它给出了'error-type'.有人知道这里发生了什么吗?
#ifndef _CPU_H
#define _CPU_H
#include <stdint.h>
typedef struct cpu_registers
{
union
{
struct
{
uint8_t f;
uint8_t a;
};
uint16_t af;
};
union
{
struct
{
uint8_t c;
uint8_t b;
};
uint16_t bc;
};
} cpu_registers;
#endif /* _CPU_H */
Run Code Online (Sandbox Code Playgroud)
#include "CPU.h"
cpu_registers regs;
regs.af = 0xFFFF;
Run Code Online (Sandbox Code Playgroud)
以下是使用clang编译时出现的错误:
CPU.c:4:1: error: unknown type name 'regs'
regs.af = 0xFFFF;
^
CPU.c:4:5: error: expected identifier or '('
regs.af = 0xFFFF;
^
2 errors generated.
Run Code Online (Sandbox Code Playgroud)