#include works fine, but, as in C, it's just textual inclusion (it
really is nothing complicated ;-)). So it's all as if you just wrote:
module ...
implementation
{
#ifndef C_CODE
#define C_CODE
void Hello();
#endif
event void Boot.booted()
{
call Timer0.startPeriodic( 250 );
}
event void Timer0.fired()
{
Hello(); //Hello() is a function which is inside my C code
}
}
which therefore just declares Hello() as an internal function inside BlinkC.
In nesC, C functions must be declared before the module/implementation
(or interface) part of a file. So what you wanted to do was:
/* nesC code*/
#include "c_code.h"
module ...
implementation
{
event void Boot.booted()
{
call Timer0.startPeriodic( 250 );
}
event void Timer0.fired()
{
Hello(); //Hello() is a function which is inside my C code
}
}
On Jan 30, 2008 6:37 AM, AIGroup <[EMAIL PROTECTED]> wrote:
> I believed...
> include directive works well. I have problem to edit the Makefile in order
> to compile also the C file.
Yes, you then also of course need to compile and link with your C
code. Several ways to do that... The easiest in this case at least is
probably to add
LDFLAGS = c_code.c
to your Makefile, which should cause ncc to compile and link c_code.c
with your nesC app. A slightly more traditional Makefile approach
would have you add
LDFLAGS = c_code.o
c_code.c: c_code.h
$(CC) -o c_code.o <your favourite flags> c_code.c
to your Makefile... (don't cut & paste the text above, the character
before $(CC) needs to be a tab to keep make happy, in this email it's
some spaces...)
David Gay
>
>
> 2008/1/30, AIGroup <[EMAIL PROTECTED]>:
>
> > Hi all.
> > I would like to include some routines in my nesC code as follows
> (considering the BlinkApp for example):
> > /* nesC code*/
> > implementation
> > {
> > #include "c_code.h"
> >
> > event void Boot.booted()
> > {
> > call Timer0.startPeriodic( 250 );
> > }
> >
> > event void Timer0.fired()
> > {
> > Hello(); //Hello() is a function which is inside my C code
> > }
> > }
> > -------------------------
> > /*C code*/
> > /*c_code.h*/
> >
> > #ifndef C_CODE
> > #define C_CODE
> >
> > void Hello();
> >
> > #endif
> >
> > ---------------
> > /* c_code.c */
> >
> > #include "c_code.h"
> >
> > void Hello()
> > {
> > printf("HELLO!\n")
> > }
> > ---------------
> > Compilation terminate with success, but if i try to execute a simulation,
> this following error occurs:
> > undefined symbol: BlinkC$Hello
> > How can I solve this problem?
> > Thank you very much for your help!
> >
> >
> >
> >
>
>
> _______________________________________________
> Tinyos-help mailing list
> [email protected]
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help