嗨我在C项目中工作;不幸的是我有这个警告
  如果有人帮助我,我将不胜感激:
  这是代码
  ................................................... ...........
  ................................................... .......
  ....................................


/*--------------------------------------------------------------*/
63:static void /*  the RREQ message is send in broadcast to all
64:                neighbors through all its interfaces*/
65:send_rreq(struct route_discovery_conn *c, const rimeaddr_t *dest)
66:{
67:  rimeaddr_t dest_copy;
68:  struct route_discovery_packet *msg;
69:
70:  rimeaddr_copy(&dest_copy, dest);
71:  dest = &dest_copy;
73:
74:  packetbuf_clear();
75:  msg = packetbuf_dataptr();
76:  packetbuf_set_datalen(sizeof(struct route_discovery_packet));
77:
78:  msg->type = "0x0" ;
79:  rimeaddr_copy(&msg->dest, dest);
80: // msg->metric_type ////////// wa have chosen as default metrric type hop_count ////////
81:  msg->route_metric = 0;
82:  msg->hop_count = 0;
83:  msg->hop_limit = MAX_HOP_LIMIT;
84:
85:
86:  netflood_send(&c->rreqconn, c->seqno); // Message transmission
87:  c->seqno ++;
89:}



  这是头文件:


/*  This structure points to the information of RREQ/RREP packet*/
struct route_discovery_packet {
  // struct tlv ;
  char type;
  uint8_t seqno;
  uint8_t route_metric; // specifies the route metric of the route
  char metric_type; // pecifies the type of metric requested by this RREQ
  uint8_t hop_count; // specifies the total number of hops from the originator
  uint8_t hop_limit;
  rimeaddr_t dest;
  rimeaddr_t originator;
  rimeaddr_t local_iface_addr;

};
`/



  这是编译的结果


route-discovery.c: In function ‘send_rreq’:
route-discovery.c:76:32: erreur: invalid application of ‘sizeof’ to incomplete type ‘struct route_discovery_packet’
route-discovery.c:78:6: erreur: déréférencement d'un pointeur de type incomplet
route-discovery.c:79:21: erreur: déréférencement d'un pointeur de type incomplet
route-discovery.c:81:6: erreur: déréférencement d'un pointeur de type incomplet
route-discovery.c:82:6: erreur: déréférencement d'un pointeur de type incomplet
route-discovery.c:83:6: erreur: déréférencement d'un pointeur de type incomplet
route-discovery.c:86:32: erreur: ‘struct route_discovery_conn’ has no member named ‘seqno’
route-discovery.c:87:4: erreur: ‘struct route_discovery_conn’ has no member named ‘seqno’

最佳答案

此错误意味着在编译时看不到结构的声明。只要您仅需要指向它的指针,此方法就可以很好地工作,但是如果您想知道其大小,则必须有一个定义。

关于c - “sizeof”的无效应用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23135648/

10-10 04:14