Conditional compilation


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2008
    Location
    Bologna, Italy
    Posts
    2

    Default Conditional compilation

    Hi guys,
    I need some conditional compilation.
    Normally I use the @ifdef, @ifndef ... @endif statements to enable or disable some code and it works.
    But if I need to switch some Variabile declaration like:
    Code:
    @ ifdef Devboard
      EnterKey  VAR Key.0
      StopKey   VAR Key.1
      StartKey  VAR Key.2
    @ else
      EnterKey  VAR Key.2
      StopKey   VAR Key.0
      StartKey  VAR Key.1
    @ endif
    I obtain the error message: variable already an alias
    for each duplicate variable declaration line.

    There is another way to obtain the conditional change of assignment?
    Thk you
    Roberto

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Conditional compilation

    The @ ifdef statements only work during assembly, but that's AFTER the PBP program has been compiled.
    So it can't directly affect PBP variables.

    However, in ASM you can undefine bit variables and re-define them, which has pretty much the same effect.

    Code:
    Key       VAR PORTB
    EnterKey  VAR BIT EXT :@ #undefine EnterKey 
    StopKey   VAR BIT EXT :@ #undefine StopKey
    StartKey  VAR BIT EXT :@ #undefine StartKey
    ASM
      ifdef Devboard
        #define EnterKey  _Key,0
        #define StopKey   _Key,1
        #define StartKey  _Key,2
      else
        #define EnterKey  _Key,2
        #define StopKey   _Key,0
        #define StartKey  _Key,1
      endif
    ENDASM
    DT

  3. #3
    Join Date
    Nov 2008
    Location
    Bologna, Italy
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: Conditional compilation

    Thanks Darrel, as always, your help is effective and wellcome.
    Roberto

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts