'FILE' is unknown type in Contiki












1















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 %dn",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?










share|improve this question

























  • No idea ... but, just for fun, swap the includes: first the ones with <> followed by the ones with "".

    – pmg
    Dec 29 '18 at 18:54






  • 1





    It is declared in stdio.h, but you may have a "cut-down" implementation for embedded systems. You might simply open the stdio file you have and see if it is conditionally declared or not declared at all. You probably need to configure the system to include a filesystem. It looks like you are trying to access a file on the development host rather then the target in any case - that won't work!

    – Clifford
    Dec 29 '18 at 19:00













  • You didn't specify what compiler you use but in gcc for example you can use -E to generate a preprocessed code and search for FILE. You might need to add some #define statements or maybe it's not defined in your <stdio.h> at all.

    – Arkadiusz Drabczyk
    Dec 29 '18 at 19:58













  • thank you all for the responses. I changed the line <> and " ", it did not work. I think you were right about cut down stdio.h in contiki. I searched in src folder of e_stdio folder in Contiki, there are some files like fvwrite.h and local.h and others which used 'FILE' but I could not found the source where 'FILE' had been defined. and yes I use gcc compiler. I tried gcc -E but could not get what that meant, I'm new in C.

    – venus
    Dec 30 '18 at 5:48


















1















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 %dn",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?










share|improve this question

























  • No idea ... but, just for fun, swap the includes: first the ones with <> followed by the ones with "".

    – pmg
    Dec 29 '18 at 18:54






  • 1





    It is declared in stdio.h, but you may have a "cut-down" implementation for embedded systems. You might simply open the stdio file you have and see if it is conditionally declared or not declared at all. You probably need to configure the system to include a filesystem. It looks like you are trying to access a file on the development host rather then the target in any case - that won't work!

    – Clifford
    Dec 29 '18 at 19:00













  • You didn't specify what compiler you use but in gcc for example you can use -E to generate a preprocessed code and search for FILE. You might need to add some #define statements or maybe it's not defined in your <stdio.h> at all.

    – Arkadiusz Drabczyk
    Dec 29 '18 at 19:58













  • thank you all for the responses. I changed the line <> and " ", it did not work. I think you were right about cut down stdio.h in contiki. I searched in src folder of e_stdio folder in Contiki, there are some files like fvwrite.h and local.h and others which used 'FILE' but I could not found the source where 'FILE' had been defined. and yes I use gcc compiler. I tried gcc -E but could not get what that meant, I'm new in C.

    – venus
    Dec 30 '18 at 5:48
















1












1








1








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 %dn",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?










share|improve this question
















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 %dn",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?







c embedded stdio contiki






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 29 '18 at 19:01









Clifford

58.7k858125




58.7k858125










asked Dec 29 '18 at 18:49









venusvenus

114




114













  • No idea ... but, just for fun, swap the includes: first the ones with <> followed by the ones with "".

    – pmg
    Dec 29 '18 at 18:54






  • 1





    It is declared in stdio.h, but you may have a "cut-down" implementation for embedded systems. You might simply open the stdio file you have and see if it is conditionally declared or not declared at all. You probably need to configure the system to include a filesystem. It looks like you are trying to access a file on the development host rather then the target in any case - that won't work!

    – Clifford
    Dec 29 '18 at 19:00













  • You didn't specify what compiler you use but in gcc for example you can use -E to generate a preprocessed code and search for FILE. You might need to add some #define statements or maybe it's not defined in your <stdio.h> at all.

    – Arkadiusz Drabczyk
    Dec 29 '18 at 19:58













  • thank you all for the responses. I changed the line <> and " ", it did not work. I think you were right about cut down stdio.h in contiki. I searched in src folder of e_stdio folder in Contiki, there are some files like fvwrite.h and local.h and others which used 'FILE' but I could not found the source where 'FILE' had been defined. and yes I use gcc compiler. I tried gcc -E but could not get what that meant, I'm new in C.

    – venus
    Dec 30 '18 at 5:48





















  • No idea ... but, just for fun, swap the includes: first the ones with <> followed by the ones with "".

    – pmg
    Dec 29 '18 at 18:54






  • 1





    It is declared in stdio.h, but you may have a "cut-down" implementation for embedded systems. You might simply open the stdio file you have and see if it is conditionally declared or not declared at all. You probably need to configure the system to include a filesystem. It looks like you are trying to access a file on the development host rather then the target in any case - that won't work!

    – Clifford
    Dec 29 '18 at 19:00













  • You didn't specify what compiler you use but in gcc for example you can use -E to generate a preprocessed code and search for FILE. You might need to add some #define statements or maybe it's not defined in your <stdio.h> at all.

    – Arkadiusz Drabczyk
    Dec 29 '18 at 19:58













  • thank you all for the responses. I changed the line <> and " ", it did not work. I think you were right about cut down stdio.h in contiki. I searched in src folder of e_stdio folder in Contiki, there are some files like fvwrite.h and local.h and others which used 'FILE' but I could not found the source where 'FILE' had been defined. and yes I use gcc compiler. I tried gcc -E but could not get what that meant, I'm new in C.

    – venus
    Dec 30 '18 at 5:48



















No idea ... but, just for fun, swap the includes: first the ones with <> followed by the ones with "".

– pmg
Dec 29 '18 at 18:54





No idea ... but, just for fun, swap the includes: first the ones with <> followed by the ones with "".

– pmg
Dec 29 '18 at 18:54




1




1





It is declared in stdio.h, but you may have a "cut-down" implementation for embedded systems. You might simply open the stdio file you have and see if it is conditionally declared or not declared at all. You probably need to configure the system to include a filesystem. It looks like you are trying to access a file on the development host rather then the target in any case - that won't work!

– Clifford
Dec 29 '18 at 19:00







It is declared in stdio.h, but you may have a "cut-down" implementation for embedded systems. You might simply open the stdio file you have and see if it is conditionally declared or not declared at all. You probably need to configure the system to include a filesystem. It looks like you are trying to access a file on the development host rather then the target in any case - that won't work!

– Clifford
Dec 29 '18 at 19:00















You didn't specify what compiler you use but in gcc for example you can use -E to generate a preprocessed code and search for FILE. You might need to add some #define statements or maybe it's not defined in your <stdio.h> at all.

– Arkadiusz Drabczyk
Dec 29 '18 at 19:58







You didn't specify what compiler you use but in gcc for example you can use -E to generate a preprocessed code and search for FILE. You might need to add some #define statements or maybe it's not defined in your <stdio.h> at all.

– Arkadiusz Drabczyk
Dec 29 '18 at 19:58















thank you all for the responses. I changed the line <> and " ", it did not work. I think you were right about cut down stdio.h in contiki. I searched in src folder of e_stdio folder in Contiki, there are some files like fvwrite.h and local.h and others which used 'FILE' but I could not found the source where 'FILE' had been defined. and yes I use gcc compiler. I tried gcc -E but could not get what that meant, I'm new in C.

– venus
Dec 30 '18 at 5:48







thank you all for the responses. I changed the line <> and " ", it did not work. I think you were right about cut down stdio.h in contiki. I searched in src folder of e_stdio folder in Contiki, there are some files like fvwrite.h and local.h and others which used 'FILE' but I could not found the source where 'FILE' had been defined. and yes I use gcc compiler. I tried gcc -E but could not get what that meant, I'm new in C.

– venus
Dec 30 '18 at 5:48














1 Answer
1






active

oldest

votes


















3














Contiki does not provide/support the POSIX file API, the same way it does not have many other things (POSIX sockets API, POSIX process creation and control API). Instead, it provides its own filesystem API ("protosockets" API, "protothreads" API etc.).



There are two filesystem implementations: CFS (Contiki File System) and Coffee. You can use the functions described in the Wiki page; they are analogues to low-level POSIX file API (e.g. cfs_open is similar to POSIX open, cfs_close to POSIX close and so on). There are no analogues for buffered I/O functionality (fopen, fclose) and the FILE structure does not exist.






share|improve this answer

























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53972425%2ffile-is-unknown-type-in-contiki%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    Contiki does not provide/support the POSIX file API, the same way it does not have many other things (POSIX sockets API, POSIX process creation and control API). Instead, it provides its own filesystem API ("protosockets" API, "protothreads" API etc.).



    There are two filesystem implementations: CFS (Contiki File System) and Coffee. You can use the functions described in the Wiki page; they are analogues to low-level POSIX file API (e.g. cfs_open is similar to POSIX open, cfs_close to POSIX close and so on). There are no analogues for buffered I/O functionality (fopen, fclose) and the FILE structure does not exist.






    share|improve this answer






























      3














      Contiki does not provide/support the POSIX file API, the same way it does not have many other things (POSIX sockets API, POSIX process creation and control API). Instead, it provides its own filesystem API ("protosockets" API, "protothreads" API etc.).



      There are two filesystem implementations: CFS (Contiki File System) and Coffee. You can use the functions described in the Wiki page; they are analogues to low-level POSIX file API (e.g. cfs_open is similar to POSIX open, cfs_close to POSIX close and so on). There are no analogues for buffered I/O functionality (fopen, fclose) and the FILE structure does not exist.






      share|improve this answer




























        3












        3








        3







        Contiki does not provide/support the POSIX file API, the same way it does not have many other things (POSIX sockets API, POSIX process creation and control API). Instead, it provides its own filesystem API ("protosockets" API, "protothreads" API etc.).



        There are two filesystem implementations: CFS (Contiki File System) and Coffee. You can use the functions described in the Wiki page; they are analogues to low-level POSIX file API (e.g. cfs_open is similar to POSIX open, cfs_close to POSIX close and so on). There are no analogues for buffered I/O functionality (fopen, fclose) and the FILE structure does not exist.






        share|improve this answer















        Contiki does not provide/support the POSIX file API, the same way it does not have many other things (POSIX sockets API, POSIX process creation and control API). Instead, it provides its own filesystem API ("protosockets" API, "protothreads" API etc.).



        There are two filesystem implementations: CFS (Contiki File System) and Coffee. You can use the functions described in the Wiki page; they are analogues to low-level POSIX file API (e.g. cfs_open is similar to POSIX open, cfs_close to POSIX close and so on). There are no analogues for buffered I/O functionality (fopen, fclose) and the FILE structure does not exist.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Dec 30 '18 at 15:21

























        answered Dec 30 '18 at 9:58









        kfxkfx

        5,03621535




        5,03621535






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53972425%2ffile-is-unknown-type-in-contiki%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas