Unused variables,constants, functions subs warnings.
Posted: 08 March 2006, 12:39 PM
As programs get larger in size, is there a way that the programmer can be warned of unused variables, constants, functions and subs?
A place to discuss ZBasic and ZX series microcontrollers.
https://forum.zbasic.net/
Code: Select all
Sub Main()
Dim pin as Byte
Dim level as Byte
pin = 12
level = 2
Call PutPin(pin, level)
End Sub
Code: Select all
Sub Main()
Dim pin as Byte
var:pin (1) [not used]
Dim level as Byte
var:level (1) [not used]
pin = 12
level = 2
Call PutPin(pin, level)
0011 1a0c PSHI_B 0x0c (12)
0013 1a02 PSHI_B 0x02 (2)
0015 d4 PUTPIN
End Sub
0016 06 RET
The answer to the question is to look at the listing file and also generate the called-by and called-from lists. The compiler options to add to the PJT file are:zbasicandy wrote:As programs get larger in size, is there a way that the programmer can be warned of unused variables, constants, functions and subs?
Code: Select all
--list=<filename>
--called-by-list
--calls-list
Code: Select all
--warn=unused-param
This is a result of the lessons learnt when Don and I did some similar work for the predecessor to ZBasic called BasicX - see the bxDism utility on my website. So this is second generation technology at least (produced by a different company).stevech wrote:Impressive!
This sounds like a good idea to add to the documentation.stevech wrote:Is there a way to see what the default compiler options are?
The help text output for optimization and warning options indicates which options are in effect by default.Is there a way to see what the default compiler options are?
Code: Select all
zbasic --help-optimize
zbasic --help-warning