keil环境下,报错#70:incomplete type is not allowed,报错在struct psock

keil环境下,报错#70:incomplete type is not allowed,报错在struct psock sin,sout;

struct psock{
struct pt pt, psockpt; /* Protothreads - one that's using the psock
functions, and one that runs inside the
psock functions. */
const u8_t *sendptr; /* Pointer to the next data to be sent. */
u8_t *readptr; /* Pointer to the next data to be read. */
char *bufptr; /* Pointer to the buffer used for buffering
incoming data. */
u16_t sendlen; /* The number of bytes left to be sent. */
u16_t readlen; /* The number of bytes left to be read. */
struct psock_buf buf; /* The structure holding the state of the
input buffer. */
unsigned int bufsize; /* The size of the input buffer. */
unsigned char state; /* The state of the protosocket. */
};




已经定义了psock啊,怎么老是提示有错啊,难道要typedef,但是pt也是个结构体却没有typedef啊,我就觉得奇怪了,被这个问题困扰很久了
波淇 1年前 已收到1个回答 举报

ccoco123 幼苗

共回答了24个问题采纳率:91.7% 举报

struct psock{
.
}Psock;
struct can_state {
unsigned char timer;
Psock sin,sout;
pt outputpt;
char state;
char inputbuffer[16];
};
你这样试试

1年前 追问

3

波淇 举报

不行啊,它任然会报错说psock is undefined.

举报 ccoco123

结构在定义改成 typedef struct{ .... }Psock;

波淇 举报

你的答案都不是很对,其实那天编程有些烦躁了,这几天稍微玩了一下,原来是重复定义了,包含了两次的psock的定义,所以才会出现这种情况。因为我发现psock和pt是一样定义的,但是pt是不报错的,所以我就试图删除头文件中include头文件的那一行,错误消除了,谢谢你了,还是实践出真知啊,有些时候不能死编,要思考,哈哈。
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 17 q. 0.034 s. - webmaster@yulucn.com