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

mturon at xbow.com mturon at xbow.com
Fri Sep 9 10:49:27 PDT 2005


The nesC includes directive does not work as one would expect with #ifdef.
Use the standard C #include directive instead for compile time flags.

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

#include "SimpleCmdMsg.h"

=================================

Just for reference, in a Makefile, the ifdef syntax is also different:

ifndef $(XBOWROOT)
    XBOWROOT=%T/../contrib/xbow/tos
endif

ifeq ($(MESH),)
# Default to XMesh low power
    MESH=lp
endif

Regards,
Martin 
__________________________________________________
Martin Turon  |  Crossbow Technology, Inc.

-----Original Message-----
From: tinyos-help-bounces at Millennium.Berkeley.EDU
[mailto:tinyos-help-bounces at Millennium.Berkeley.EDU] On Behalf Of Krisakorn
Rerkrai
Sent: Friday, September 09, 2005 8:32 AM
To: tinyos-help at Millennium.Berkeley.EDU
Subject: [Tinyos-help] Using "#define" in a header used in a main
configuration component

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

_______________________________________________
Tinyos-help mailing list
Tinyos-help at Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help


More information about the Tinyos-help mailing list