Sunday, March 4, 2007

[NesC] Weird problem about typedef in header file

Environment:
Cygwin + Tinyos 1.15
gcc3.3.3

I was trying to compile a program with several structures defined by myself in a header file. And these structures are passed through some interfaces as parameters.

At first I didn't include the header file in the top level wiring configuration but only in the modules using it. However the compiler reported "conflicting types" on the parameters between my event handler definition and the "previous declaration" of that event in the interface definition file. This is weird since these two lines are exactly the same and to be perfectly cautious, I copy the definition to replace my event handler definition. It didn't work neither.

I tried to google it, no luck. Then I started to remove the parameters one by one. Finally after I removed the parameters of the structures defined by myself from the interface definition, it works. It seems although the compiler is able to translate that structure in the interface definition file into the correct type but unable to translate the ones in my application module although I included the header file as well. One solution to this problem is to replace that data structure with build-in types. That solved the problem, but it will become quite annoying.

Since it seems that the compiler have trouble in mapping the use of self-defined structures into correct definitions of those structures, I tried to include that file in the top level wiring configuration. Well, another weird thing happened. The compiler didn't recognize typedef in the header file at all.

It even complained about instructions like:

typedef uint8_t HANDLE;
The error appeared like this:

"parse error before "typedef"".

No better solutions so far. As the deadline of paper approaches, I have to give up trying on this single point and move on. Any suggestions are welcome and appreciated! Thanks!



1 comment:

xTristan said...

follow-ups:

It seems that a static variable defined after the typedef causes this problem.