[Tinyos-help] Using "#define" in a header used in a main configuration component

Krisakorn Rerkrai krisyok at gmail.com
Fri Sep 9 08:32:24 PDT 2005


Hi all,
    
     I have a minor problem with the header file declaration in a main
configuration component when using a preprocessor like #define,
#ifndef, and so on. It doesn't seems to understand my #define at all. 
Surprisingly I don't have this problem in the other configuration
components. To make more clear, this is what I tried:
[I use SimpleCmd as a simple example since it has 2 configuation files]
--------------------------------------------------------------
>> this is my Makefile:

#COMPONENT=SimpleCmd    // to make sure that I use Bcast as a main
configuration file.
COMPONENT=Bcast
include ../Makerules

>> in SimpleCmdMsg.h I simply add this 
#define TEST

>> in SimpleCmd.nc [as a child configuration]

includes SimpleCmdMsg;

configuration SimpleCmd {
  provides interface ProcessCmd;
}
implementation {
  components Main, SimpleCmdM, GenericComm as Comm, PotC, LedsC;
#ifdef TEST
  Main.StdControl -> SimpleCmdM;
  SimpleCmdM.Leds -> LedsC;
  ProcessCmd = SimpleCmdM.ProcessCmd;
  SimpleCmdM.CommControl -> Comm;
  SimpleCmdM.ReceiveCmdMsg -> Comm.ReceiveMsg[AM_SIMPLECMDMSG];

  SimpleCmdM.Pot -> PotC;
#endif
}

>> It works fine as usual.
>> But when I try this #preprocessor in Bcast.nc [as a main configuration] 

includes SimpleCmdMsg;

configuration Bcast { }
implementation {
  components Main, BcastM, SimpleCmd, GenericComm as Comm, LedsC;
#ifdef TEST
  Main.StdControl -> BcastM;

  BcastM.Leds -> LedsC;
  BcastM.ProcessCmd-> SimpleCmd.ProcessCmd;
  BcastM.CommControl -> Comm;
  BcastM.SendCmdMsg -> Comm.SendMsg[AM_SIMPLECMDMSG];
  BcastM.ReceiveCmdMsg -> Comm.ReceiveMsg[AM_SIMPLECMDMSG];
#endif
}

>> It doesn't work like I don't define TEST anywhere. 
-----------------------------------------------------------

Am I missing something here?
Any explaination would be appreciated.

Regards,
Krisakorn



More information about the Tinyos-help mailing list