SX/B 2.00.28 Beta now supports nested Conditional Compile Directives
Bean
Posts: 8,129
I can't remember who asked for this feature...I think is was Peter ???
But I have implemented it, so I'd like you guys to give it a good test case.
Here is what I used to test it:
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The needy are many, the deserving are few.
·
But I have implemented it, so I'd like you guys to give it a good test case.
Here is what I used to test it:
DEVICE SX28, OSC4MHZ FREQ 4_000_000 temp1 VAR BYTE PROGRAM Start NOSTARTUP Start: ' This three defines TEST0, TEST1 and TEST2 determine which of the seven FOR statements are compiled '{$UNDEFINE TEST2} '{$DEFINE TEST1} '{$DEFINE TEST0} '{$IFNDEF TEST2} '{$IFNDEF TEST1} '{$IFNDEF TEST0} FOR temp1 = 0 TO 255 '{$ELSE} FOR temp1 = 1 TO 255 '{$ENDIF} '{$ELSE} '{$IFNDEF TEST0} FOR temp1 = 2 TO 255 '{$ELSE} FOR temp1 = 3 TO 255 '{$ENDIF} '{$ENDIF} '{$ELSE} '{$IFNDEF TEST1} '{$IFNDEF TEST0} FOR temp1 = 4 TO 255 '{$ELSE} FOR temp1 = 5 TO 255 '{$ENDIF} '{$ELSE} '{$IFNDEF TEST0} FOR temp1 = 6 TO 255 '{$ELSE} FOR temp1 = 7 TO 255 '{$ENDIF} '{$ENDIF} '{$ENDIF} NEXT END
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The needy are many, the deserving are few.
·
Comments
I will download and install later today! I recently was trying to do some stuff where nested compiler directives would have been very nice!
RS_JIM
Nested conditionals were already possible, but the condition was reset
upon first $endif.
I assume that is no longer the case and we have truly nested conditionals now.
regards peter
Yes, they should be honest and truly nest-able now.
The example program I show above will only generate a single FOR line depending on if TEST0, TEST1 and TEST2 are defined or undefined.
Let me know if you get a chance to test it.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The needy are many, the deserving are few.
·
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
·
I will be trying some of the nested conditional directives later today, will let you know how they work!
RS_JIM
I'll try it out over the next weeks.
- Howard
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The following does not compile correctly:
'
' Conditional Compilation Symbols
'
'{$DEFINE SERIAL}
'
'
'
' INTERRUPT
'
'
'{$IFDEF SERIAL}
INTERRUPT NOPRESERVE 230_400
'{$ELSE}
INTERRUPT NOPRESERVE 100_000
'{$ENDIF}
'
All of my other conditionals compile correctly including a nested one
'{$IFDEF SERIAL}
'{$IFDEF LCD_DSP}
'{$ELSE }
'{$ENDIF}
IT Tries to use both interupt rates and the assemblier complains about overwriting the same program location. I can also tell from the __INTOPTION that it is picking up the second value (10,000) as it equats __INTOPTION to $80 not $88. If I don't use the conditional and just comment out the interupt option I don't want, it compiles/assembles correctly. I have conditionals burried in the interupt load file and that is working correctly.
RS_JIM
'{$ENDIF}
Could you post the entire program.
I tried this and it seem to work properly.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
·
Thanks for checking.· Problem was with a redundant declaration of the program ID!
RS_JIM
I find it very confusing and odd that the syntax for these directives starts with the· '· comment delimiter.· Does that mean these lines can't be commented-out??· Using '' <-- that's two '· does not seem to work; the conditional compile is taken regardless.··· And, I must admit that I'm curious about the reason for implementing these this way.
example:
'{$DEFINE Bluetooth}······························ 'compile Bluetooth code if defined (true)
''{$DEFINE COMport}································ 'compile serial port I/O if defined (true)
'{$DEFINE EnFilter}······························· 'enable digital filtering of sample data
''{$DEFINE DebugMode}······························ 'compile debug statements if defined (true)
''{$DEFINE DualAxis}·
I could see changing DEFINE to unDEFINE, but it gets more difficult if I want to comment out the IFDEF...ELSE...ENDIF's
Got·any helpful guidance?
-- BrooksL
What does that version number refer to? SX/B compiler version?
Is SX/B 1.51.03 no longer the latest?
--BrooksL
We moved past 1.5x a long time ago -- but you have to install it manually (the IDE installer hasn't been updated with the 2.x files). You can find what you need in a sticky post at the top of the SX forum.
You cannot "comment out" conditional directives -- you can modify the define directive to turn things on and off. I tend to do things like this:
' {$DEFINE DEBUGGING}
...and when I want it off I change it to:
' {$DEFINE DEBUGGING_OFF}
I use conditional compile directives a lot for feature options. This ' comment delimter in the SX/B directive syntax is creating an annoyance for the porting of other code. ...and I can forsee it causing possible future difficulty.
Today for example, I finally spotted '{$IF ... } instead of '{$IFDEF ... } and '{$IF ... } appears as a comment to the SX/B compiler so it fails to generate a syntax error!? That took hours to notice - as will any others that get in there!
-- Brooks
http://forums.parallax.com/showthread.php?p=780347
Thanks,
PeterM
' {$DEFINE DEBUGGING}
...and when I want it off I change it to:
' {$DEFINE DEBUGGING_OFF}
---
The confusion comes in that with the ' comment delimiter, you can change it to just about anything:
'{$DEFINE DEBUGGING_OFF} or
'{$UNDEFINE DEBUGGING} or
'{$NODEFINE DEBUGGING} or
'{$STOPDEF DEBUGGING} or
'{$DEF DEBUGGING} ....
All but the first has the same effect and the compiler won't check or enforce a standard syntax with error messages - because they look like comments. :-/ More dangerous; what if you have a define (or any) directive like '{$DEFINE DEBUGGING} or {$DEFINE DEBUGGING} floating somewhere in a real 'comment statement - wil lthe compiler process it as a valid directive??
...Since SX/B 2.x is in beta... can this ' issue be "fixed" before release? - not just because it's bugging me right now (obviously, I'll have to work around it for the time being), but because there seems to be a lot of potential problems with it.
-- BrooksL
No, they will not.
'{$DEFINE XYZ}
above means XYZ is defined (true)
''{$DEFINE XYZ}
not defined
' { $DEFINE XYZ}
not defined
etc.
Not sure what the issue is? Rather then even "undefining" I would just comment out the define, e.g.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When the going gets weird, the weird turn pro. -- HST
1uffakind.com/robots/povBitMapBuilder.php
1uffakind.com/robots/resistorLadder.php
Thanks for listening. And, it sure would be nice if conditional compile directives were recognized as regular keyword syntax...
I'm hoping the answer is yes and that there's some guidance somewhere, but it's not obvious because I couldn't find an affirm or decline nor any mention in the SX/B manual.
-- BrooksL
-- BrooksL