编译nesc时指针错误

时间:2016-06-03 03:01:33

标签: pointers tinyos nesc

我在nesc中有以下方法/事件。我收到了错误

event message_t* Receive.receive(message_t* bufPtr,
void* payload, uint8_t len) {
dbg("RadioCountToLedsC", "Received packet of length %hhu.\n", len);
radio_count_msg_t* adammsg = (radio_count_msg_t*) payload;
val =adammsg -> counter;
dbg("RadioCountToLedsC", "The current summation is: %d \n", val);
return bufPtr;
}

在这段代码的第4行。具体错误是: “'*'之前的语法错误。然后说adammsg在下一行中未声明

谁能告诉我我的错误可能是什么?我已经坚持了一段时间,这让我疯了。我正在研究Tinyos中包含的RadioCountsToLeds应用程序。具体来说,我试图注入数据包 - 将它们发送到节点 - 然后对存储在数据包中的信息进行计算。

谢谢!

1 个答案:

答案 0 :(得分:1)

在C(和nesC中)中,变量的所有声明必须位于函数的开头。所以:

event message_t* Receive.receive(message_t* bufPtr,
void* payload, uint8_t len) {
radio_count_msg_t* adammsg = (radio_count_msg_t*) payload;
dbg("RadioCountToLedsC", "Received packet of length %hhu.\n", len);
val =adammsg -> counter;
dbg("RadioCountToLedsC", "The current summation is: %d \n", val);
return bufPtr;
}