Conditional compile


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2009
    Posts
    737

    Default Conditional compile

    Hi,
    I'm trying to create include file. I need way to create conditional compile based on whether variable is defined or not in main file.
    Something like this:
    Code:
        #IFNDEF TmpB
            TmpB VAR BYTE
        #ENDIF
    If variable is all ready defined, it won't compile just show error:Bad defined value
    If variable isn't defined then I got syntax error.
    Code:
    #IFDEF Counter2
         Counter2=Counter2+1
    #ENDIF
    For this, if variable isn't define, it's ok, but if is defined then I get Bad defined value.

    Is there way to do that?

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,520


    Did you find this post helpful? Yes | No

    Default Re: Conditional compile

    Hi,
    I might be wrong but I don't think you can do that.
    The #IFNDEF Tmp2 will check if you've previoulsy not done #DEFINE Tmp2, where Tmp2 in this case a compile-time constant Tmp2 (not a PBP constant OR PBP variable).

    So, the only way to do it is to also define "something" in the main file, at the same time as you declare your Tmp2 variable and then check that "something" - not ideal but I think (though I'd like to be wrong) it's the only way.
    Code:
    Tmp2 VAR BYTE
    #DEFINE VarCreated
    Code:
    #IFNDEF VarCreated
      Tmp2 VAR BYTE
    #ENDIF
    Again, I hope I'm wrong because I can see what you're trying to do could be useful.

    /Henrik.

  3. #3
    Join Date
    Sep 2009
    Posts
    737


    Did you find this post helpful? Yes | No

    Default Re: Conditional compile

    Thanks.
    I know that I could use define for each var, but then I need lot of them and probably it would be messy. Especially if I forget to put one or two define
    That is last option...
    If conditional compile depend on variables, there is almost no way to overlook some of option's.

Similar Threads

  1. Conditional compilation
    By ro37bis in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 10th July 2011, 23:02
  2. Conditional default config's
    By cncmachineguy in forum PBP Wish List
    Replies: 10
    Last Post: - 8th May 2011, 19:47
  3. help with PIC16F628 conditional program
    By joseph in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 5th July 2010, 13:54
  4. Conditional Defines?
    By Kamikaze47 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 21st June 2010, 22:08
  5. Conditional Compilation
    By milestag in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd March 2006, 20:29

Members who have read this thread : 2

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