[Tinyos-help] Call external function of C in nesC
Philip Levis
pal at cs.stanford.edu
Fri Sep 21 13:56:59 PDT 2007
On Sep 21, 2007, at 1:52 PM, David Gay wrote:
> On 9/21/07, Philip Levis <pal at cs.stanford.edu> wrote:
>> On Sep 21, 2007, at 2:06 AM, Chan kenniel wrote:
>>
>>> Dear all,
>>>
>>> We are about to make a nesc program testing application. The
>>> application will insert some functions into the source code so that
>>> the running environment can be recorded. Something like:
>>> source:
>>> While (i)
>>> {
>>> ...
>>> i++;
>>> }
>>> inserted:
>>> while(i)
>>> {
>>> record(i) //inserted code
>>> ...
>>> i++
>>> }
>>> The problem comes that current record() is written by c. And when I
>>> try to compile the inserted code, and error of implicit declaration
>>> occurred. I am wondering if there is any way I can make my function
>>> recognized by the compiler, just like those familiar functions such
>>> as memcpy or printf, which can be recognized by nesc compiler?
>>>
>>
>> Just like in C, make an include file. The trickier part is linking
>> the function in.
>
> Actually there's nothing particularly tricky needed. You link in
> separately-compiled C code just the same as you would in a regular C
> project, e.g., if your C function is in mylib.o and your nesC app is
> myapp.nc, then you would do:
Hey, all I'm saying is that the TinyOS build system is trickier than
#include
Trickier is a comparative, not an absolute. ;)
Phil
More information about the Tinyos-help
mailing list