Cooja - C中的预期声明说明符

时间:2018-05-09 08:17:32

标签: c compiler-errors contiki cooja

我目前正在开发基于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

谢谢!

1 个答案:

答案 0 :(得分:0)

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

int main () {
  etimer_set(&et, PERIOD);
  return 0;*
}