-1

我目前正在研究基于 Contiki-NG 和 Cooja 的项目,我正在尝试在网络模拟器 Cooja 中的 Sky mote 上实现我的 C 代码,但出现以下错误:

code.c:5:12: error: expected declaration specifiers or '...' before '&' token
code.c:5:17: error: expected declaration specifiers or '...' before numeric constant
../../Makefile.include:347:recipe for target 'code.c' failed
make: *** [code.o] Error 1
Process returned error code 2

我试图在其他帖子上找到解决方案,但没有找到任何答案。这是我的c程序如下:

#include "contiki.h"
#include <stdio.h>
#define PERIOD CLOCK_SECOND*2
static struct etimer et;   // Define the timer
etimer_set(&et, PERIOD);   // Set the timer

/* Definition of the processes (actually a protothread) */
   PROCESS(blink_LED, "blink_LED");

/* Load this process at boot */
   AUTOSTART_PROCESSES(&blink_LED);

/* The process */
   PROCESS_THREAD(blink_LED,ev,data)
   {
    /* Application starts */
       PROCESS_BEGIN();

    /* Main loop of the application */
       while(1){
                etimer_set(&et, PERIOD);
                PROCESS_WAIT_EVENT();
                printf("Event executed \n");

                if(etimer_expired(&et)){
                   printf("Timer RESET \n");    
                   etimer_reset(&et);
                }   

       }
    /* End of the process */
      PROCESS_END();
}

错误似乎来自这一行:

etimer_set(&et, PERIOD);   // Set the timer

谢谢!

4

1 回答 1

0

指令etimer_set(&et, PERIOD);调用函数etimer_set。编译器抱怨是因为它需要一个声明。您不能直接调用您编写的指令。例如这里是函数main调用的声明etimer_set

int main () {
  etimer_set(&et, PERIOD);
  return 0;*
}
于 2018-05-09T08:32:08.270 回答