Why when I asm or hex this source file, no error shows up. Note the DataCount value is messed up.
I am using some sample codes to learn how to use and how the compiler reacts to illigal syntax or values, and what it does with them.
Syntax errors show up.
Using V 0.97.0
'Stop program when EEPROM is full If DatacCount = 2abc55 thenSetFullLightOn'Turn on the lightEnd'End the program End If .
This is just a snippit of the original source code that compiles fine without the intended error.
Last edit: Paul Haug 2017-03-03
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I am wondering why the GCB compiler does not flag a error on the statement containg an obvious (to me) value that is not a value within the bounds of a number 0-255 ?
Such as what is in the above example listing snippit *= 2abc55 *
Last edit: Paul Haug 2017-03-03
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Since 2abc55 is not a valid number the compiler assumes you meant to it to be a variable and sets aside a memory location for a variable named 2abc55. You can see this bye opening the ASM and looking at the variable section. ( Open ASM with Shift + F7)
This is partly why #Option Explicit was added. Option explicit requires that all variables in source code be explicitly declared with a DIM statement. Then these kind of errors are easily caught by the compiler.
If 2abc55 was ment to be a hex value then the "0x" Prefix need to be used eg. 0x2abc55
So try to compile the code below and see what happens. Then remove "option explicit" and change the number to 0x2abc55 and see what happens.
I recommend using option explict as a matter of habit.
#Chip16F1847,32#ConfigOSC=INTOSC,MCLRE=OFF,WDTE=OFF#OptionExplicit'// ADDED #define FullLight PORTA.0DIMDatacountasLONG' very large number Do Datacount++ If DatacCount = 2abc55 thenSetFullLightOn'Turn on the lightEnd'End the program End IfLoop
Last edit: William Roth 2017-03-04
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks, just what I needed. I now remember fainty reading about #Option Explicit
Again, thanks.
Makes perfect sense the way you explained it.
Will also remember to add your #config statement, great reminder.....
Last edit: Paul Haug 2017-03-04
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Why when I asm or hex this source file, no error shows up. Note the DataCount value is messed up.
I am using some sample codes to learn how to use and how the compiler reacts to illigal syntax or values, and what it does with them.
Syntax errors show up.
Using V 0.97.0
This is just a snippit of the original source code that compiles fine without the intended error.
Last edit: Paul Haug 2017-03-03
Using V 0.97.00
.
Sorry, just figured out how to edit above, I'll get there.
Last edit: Paul Haug 2017-03-03
Error flag. Do you mean a type error? Or, something else?
I am wondering why the GCB compiler does not flag a error on the statement containg an obvious (to me) value that is not a value within the bounds of a number 0-255 ?
Such as what is in the above example listing snippit *= 2abc55 *
Last edit: Paul Haug 2017-03-03
Since 2abc55 is not a valid number the compiler assumes you meant to it to be a variable and sets aside a memory location for a variable named 2abc55. You can see this bye opening the ASM and looking at the variable section. ( Open ASM with Shift + F7)
This is partly why #Option Explicit was added. Option explicit requires that all variables in source code be explicitly declared with a DIM statement. Then these kind of errors are easily caught by the compiler.
If 2abc55 was ment to be a hex value then the "0x" Prefix need to be used eg. 0x2abc55
So try to compile the code below and see what happens. Then remove "option explicit" and change the number to 0x2abc55 and see what happens.
I recommend using option explict as a matter of habit.
Last edit: William Roth 2017-03-04
Thanks, just what I needed. I now remember fainty reading about #Option Explicit
Again, thanks.
Makes perfect sense the way you explained it.
Will also remember to add your #config statement, great reminder.....
Last edit: Paul Haug 2017-03-04