作业帮 > 综合 > 作业

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

来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/09/22 19:32:11
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啊,我就觉得奇怪了,被这个问题困扰很久了
keil环境下,报错#70:incomplete type is not allowed,报错在struct psock
struct psock{
.
}Psock;
struct can_state {
unsigned char timer;
Psock sin,sout;
pt outputpt;
char state;
char inputbuffer[16];
};
你这样试试
再问: 不行啊,它任然会报错说psock is undefined.
再答: 结构在定义改成 typedef struct{ .... }Psock;
再问: 你的答案都不是很对,其实那天编程有些烦躁了,这几天稍微玩了一下,原来是重复定义了,包含了两次的psock的定义,所以才会出现这种情况。因为我发现psock和pt是一样定义的,但是pt是不报错的,所以我就试图删除头文件中include头文件的那一行,错误消除了,谢谢你了,还是实践出真知啊,有些时候不能死编,要思考,哈哈。