I am trying to test writing in a file in Contiki. here is the code I used :
#include "contiki.h"
#include <stdio.h>
#define LEN 256
PROCESS(test_process, "Coffee test process");
AUTOSTART_PROCESSES(&test_process);
PROCESS_THREAD(test_process, ev, data)
/**/
{
PROCESS_BEGIN();
FILE * fp;
int i;
/* open the file for writing*/
fp = fopen ("/home/user/contiki/examples/mySim/1.txt","w");
/* write 10 lines of text into the file stream*/
for(i = 0; i < 10;i++){
fprintf (fp, "This is line %d\n",i + 1);
}
/* close the file*/
fclose (fp);
PROCESS_END();
}
I get this error message after compiling in Cooja simulator:
test.c: In function ‘process_thread_test_process’: test.c:12:1: error: unknown type name ‘FILE’ test.c:15:4: warning: implicit declaration of function ‘fopen’ [-Wimplicit-function-declaration] test.c:15:7: warning: assignment makes pointer from integer without a cast [enabled by default] test.c:19:8: warning: implicit declaration of function ‘fprintf’ [-Wimplicit-function-declaration] test.c:19:8: warning: incompatible implicit declaration of built-in function ‘fprintf’ [enabled by default] test.c:23:4: warning: implicit declaration of function ‘fclose’ [-Wimplicit-function-declaration] make: *** [test.co] Error 1 Process returned error code 2
does anyone has any idea about the problem?
<>followed by the ones with"". - pmg-Eto generate a preprocessed code and search forFILE. You might need to add some #define statements or maybe it's not defined in your<stdio.h>at all. - Arkadiusz Drabczyk