Cooja - ожидаемые деклараторы в C - PullRequest
0 голосов
/ 09 мая 2018

В настоящее время я работаю над проектом, основанным на Contiki-NG и Cooja, и пытаюсь внедрить свой код C на мотылке Sky в сетевом симуляторе Cooja, но я получил следующую ошибку:

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 голосов
/ 09 мая 2018

Инструкция etimer_set(&et, PERIOD); вызывает функцию etimer_set. Компилятор жалуется, потому что ожидает объявления. Вы не можете напрямую вызывать инструкцию, подобную той, которую вы написали. Например, вот объявление функции main, вызывающее etimer_set:

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