nesC files using functions of C file

338 Views Asked by At

I help some help to understand while my source don't compile, the main errors report are :

SerialC.nc:43: syntax error before `&'
SerialC.nc:43: warning: return-type defaults to `int'
SerialC.nc:43: conflicting types for `startList'

In my implementation I am working with an header file to define my struct and interfaces to be access in nesC file, one of my doubts is about struct! Can I define a struct like in C to run in nesC?

My code to header file:

typedef struct {
    float Knowledge_base[MAX_TAM];
    int control; 
}Temp;

void startList(Temp* knowledge_base);

void knowledge_base_control(Temp* knowledge_base, float temp_real);

My .c file :

void startList(Temp* knowledge_base){
    int i;
    knowledge_base->control=0;
    for (i=0; i<MAX_TAM; i++){
        knowledge_base[i]=0;
    }
};

Before all declarations and implementations I am trying use that in my nesC file, but I get some error in output.

My nesC file :

#include "ESA.h"

Temp knowledge_base_real;

startList(&knowledge_base_real);
1

There are 1 best solutions below

5
On

Function definition should look like this:

void startList(Temp* knowledge_base){
    int i;
    knowledge_base->control=0;
    for (i=0; i<MAX_TAM; i++){
        knowledge_base->Knowledge_base[i]=0; // changed here
    }
} // remove ; here

You need to access Knowledge_base array inside knowledge_base struct. Remove ; at the end of function definition.