Hi Tony,
That's something I didn't try. Though it's probably not the most
graceful solution, I got impatient and ended up just consolidating all of
the C code I wanted to use into one big .c file so that I never had to use
any header files with just the function prototypes listed. When I #included
the .c file at the beginning of the *M.nc file, I got the same error - parse
error just before the first line of code. It then occurred to me to move
the #include to the beginning of the implementation section of the module.
That worked. It's quite possible that it could have worked the original way
had I included the *.h file at the beginning of the implementation before I
jammed everything into one file.
Either way, your comments were invaluable.
Thanks!
-Mat
> -----Original Message-----
> From: Tony Mancill [mailto:[EMAIL PROTECTED]
> Sent: Thursday, April 05, 2007 6:25 PM
> To: Mat Kotowsky
> Cc: [EMAIL PROTECTED]
> Subject: Re: [Tinyos-help] can I write to a file using nesC
>
> Hi Mat,
>
> if foo is in an external library, maybe you need to declare
> it as an extern so the compiler knows that the linker will
> fix up the reference later?
>
> tony
>
> Mat Kotowsky wrote:
> > Steve,
> >
> > In the message below, you indicated that you can make
> calls to C
> > functions from within nesC code. I'm attempting to do so
> by following
> > your instructions, but the nesC compiler exits with a parse error
> > before a line that looks like
> >
> > void foo(char bar);
> >
> > which is the prototype of the C function that I want to
> call as it is
> > declared in the header file. Can you give me any advice as
> to how to
> > what might be causing this error?
> >
> > Thanks,
> > -Mat
> >
> >
> >
> >
> > ----------------
> >
> >
> > Yes, you can make calls to C functions from nesC code. You
> don't need
> > to use the C,spontaneous attribute if you place your C code in a .c
> > file and compile with the appropriate gcc compiler. IMHO, it's
> > easiest to then bundle the object files into a library file
> (.a), and
> > reference it from your nesC Makefile via:
> >
> > LDFLAGS += path/to/your/libfile.a
> >
> > Your C library will require a header file to provide function
> > prototypes and
> >
> > other definitions for code using your library, so you'll
> also need to
> > tell your nesC build where to find that header:
> >
> > CFLAGS += -Ipath/to/your/include/dir
> >
> > Then, all you have to do in a nesC component which wishes to use
> > functions exported from your libfile.a is to #include the prototype
> > header and call the functions directly.
> >
> > All the best,
> > Steve
> >
> > _______________________________________________
> > Tinyos-help mailing list
> > [email protected]
> >
> https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-h
> > elp
>
>
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help