5.0.8 #Directive Errors

hippy

Technical Support
Staff member
5.0.8, Advanced Compiler, PICAXE-08 selected. Gives a "Error: #Directive error - #endif without #if(n)def", on the #ERROR line which is technically correct, note the #IF is not a #IFDEF in the second case, but that's a weird place to present the error. In fact I only noticed that error having posted and re-read what I'd posted.

<code><pre><font size=2 face='Courier'>#IFNDEF PICAXE08
#IFNDEF PICAXE08M
#ERROR Must be PICAXE-08 or 08M
#ENDIF
#ENDIF

#IF PICAXE08M
SYMBOL pwmOutPin = 2
#ENDIF </font></pre></code> Remove the second #IF-#ENDIF and it gives the error text as specified by #ERROR, however, I thought compiling for an 08 automatically created the PICAXE08 symbol ?

Edited by - hippy on 28/03/2007 19:52:20
 

hippy

Technical Support
Staff member
Maybe it's a more fundamental problem ...
This is okay ...<code><pre><font size=2 face='Courier'>#DEFINE FRED
#IFNDEF FRED
#ERROR FRED not defined
#ENDIF </font></pre></code> This fails ...<code><pre><font size=2 face='Courier'>#DEFINE FRED
#IFNDEF FRED
#IFNDEF BILL
#ERROR FRED not defined
#ENDIF
#ENDIF </font></pre></code>
 

Technical

Technical Support
Staff member
If you are using the 08M and want it defined you must add

#PICAXE 08M

to your program.

You can then use
#IFDEF 08M
(not #IFDEF PICAXE08M which you used)

The 08M definition is not added unless you use the PICAXE directive.

#IFDEF / #IFNDEF cannot currently be nested, although this is a planned feature for the next release.

Try this instead:

#PICAXE 18X
;#PICAXE 08
;#PICAXE 08M


#IFDEF 08
#DEFINE IS8
#ENDIF

#IFDEF 08M
#DEFINE IS8
#ENDIF

#IFNDEF IS8
#ERROR Must be PICAXE-08 or 08M
#ENDIF

#IFDEF 08M
SYMBOL pwmOutPin = 2
#ENDIF

Edited by - Technical on 28/03/2007 23:56:56
 

hippy

Technical Support
Staff member
Thanks for the clarification, and my mistake with &quot;PICAXE08&quot; etc.
 

hippy

Technical Support
Staff member
<i>The 08M definition is not added unless you use the PICAXE directive. </i>

Can we change that in future please, so the compiler adds it and compilation is entirely automatic and based upon what the user selects in View-&gt;Options ?

Otherwise it means the user has to edit a program to specify which PICAXE it's for. I'd like to be able to download the same source program ( with conditionally compiled code in it ) to an 08M or an 18X for example (*) and not have to keep editing the source code, or maintaining two copies of it to do so. That isn't really in the spirit of full conditional compilation.

(*) I know that sounds odd, but if one has two IR transmitters, one based upon an 08M and another on an 18X, then there's no reason the same IRTX.BAS shouldn't be downloadable into either ( indeed any ) with no changes other than View-&gt;Options. Conditional compilation would do little except initialise then use the required pins as pre-defined by the target hardware, the majority of the processing code would be identical, and the resultant board assembly functionally equivalent.
 
Top