The solution for this problem is to have a "types.h" file that you
include with the includes keyword (this file contains all of your
typedefs, enums, etc.), and a "const.h" file that you include with an
actual #include (this file only has #define constants and macros in it,
no C code). You have to be careful, however, about how you do it. The
only way to get it to work is to do the includes keyword at the top of
your source file, and the #include "types.h" immediately after the
"implementation {" keyword. For example:
includes types;
configuration foo {
}
implementation {
#include "const.h"
// ....
}
or
includes types;
module {
}
implementation {
#include "const.h"
}
That's how I do it, anyway.
Aaron
On Oct 19, 2004, at 11:06 AM, David Gay wrote:
[EMAIL PROTECTED] wrote:
Hi,
I have searched the archives for this matter, but I have not found
anything.
When I use the statement
includes incfile;
in e.g. myprogM.nc and in incfile.h has a line with
#define SOME_DEF 1
then this define is not defined in myprogM.nc. I get an error saying,
that
SOME_DEF is not defined, when I compile my program. I am using ncc
1.1.2:
[EMAIL PROTECTED] Blink]$ ncc --version
ncc: 1.1.2
avr-gcc: avr-gcc (GCC) 3.3-tinyos
Am I doing something wrong or is this a bug?
Files are preprocessed before 'includes ...' statements are handled.
So #define's are not visible until the next file is loaded. Do you
actually need to use #define ? (enum { SOME_DEF = 1} will work better
as long as you're not using #ifdef).
David Gay
_______________________________________________
Tinyos-help mailing list
[EMAIL PROTECTED]
http://mail.Millennium.Berkeley.EDU/mailman/listinfo/tinyos-help
_______________________________________________
Tinyos-users mailing list
[EMAIL PROTECTED]
http://mail.Millennium.Berkeley.EDU/mailman/listinfo/tinyos-users