Disclaimer - I know nothing about Swordfish, I don't own a PIC18F4321 and I have no idea what LCD display you are using...
From page 46 of Swordfish Compiler Language Reference Guide:
============================================================
Code:
#option
#option identifier [= expression]
Creates an option identifier. An option identifier is global and identical to the #define directive in every way, except for two main differences. Firstly, an option identifier can be seen and used in the declaration block of a user program. For example,
Code:
#option BUFFER_SIZE = 64
const MyBufferSize = BUFFER_SIZE
In the above example, the program constant MyBufferSize becomes equal to 64, as this is the value assigned to the option identifier BUFFER_SIZE. It is important to note that a user program identifier will always take precedence over an option directive. For example,
Code:
#option BUFFER_SIZE = 64
const BUFFER_SIZE = 16
const MyBufferSize = BUFFER_SIZE
In this example, MyBufferSizebecomes equal to 16. The other difference between option and define directives is that re-declaring an option twice, using the same identifie,r will not cause an error. For example,
Code:
#option BUFFER_SIZE = 64
#option BUFFER_SIZE = 16
In this example, BUFFER_SIZE will become equal to 64, which is the first option found by the preprocessor. The second declaration of BUFFER_SIZE is ignored.
This capability may appear a little redundant at first, but it's an extremely useful technique to enable users to configure a module from their main program code.
============================================================
In my opinion the Swordfish Compiler directive "#option" seems to be a method to inject syntax bugs in a way the compiler will not find.
This issue seems to concern the developers as the next directive described on page 47 is "IsOption(Identifier)".
This directive is used to validate that a symbol declared using the #option directive is a member of a valid list of options.
The syntax of the example in the Reference Guide on page 47 is wrong, it is missing the #else part.
The correct example should be something like:
Code:
#if IsOption(USART_LS) and not(USART_LS in(true, false))
#error USART_LS, "Invalid option. LS must be TRUE or FALSE."
#else
#option USART_LS = false
#endif
Note that threads involving MrDEB can run a bit long, see:
I am starting out with swordfish code to read a 4 x 4 switch matrix but something is wrong with my case select It shows an incompatible type error? I tried inserting comas etc but?? Maybe just go with a bunch of IF THEN statements?? DEVICE = 18F24k20 ' Tell the compiler what chip we are...
www.electro-tech-online.com