Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Print42 library throws error with --explicit option
#2
(03-13-2021, 10:59 AM)georgeo Wrote: Hi everyone,

I'd like to use --explicit to force me to define all variables before using them, to reduce the risk of bugs. However, I see an issue because my program uses the Print42 library and it contains a definition that seems to violate the --explicit option.

Specifically, if you try to compile a program that includes Print42 library, using --explicit, you will see an error something like:

Code:
C:/opt/zxbasic-1.14.0/zxbasic/src/arch/zx48k/library/print42.bas:16: error: Undeclared variable "printAt42Coords"
C:/opt/zxbasic-1.14.0/zxbasic/src/arch/zx48k/library/print42.bas:17: error: Undeclared variable "printAt42Coords"

I considered updating the library source, so that printAt42Coords is defined. However, printAt42Coords is a code label, not a normal variable. The compiler complains because the label is dereferenced with an @printAt42Coords operation to work out the address at which to store the current coordinates:

Code:
SUB printat42 (y as uByte, x as uByte)
    POKE @printAt42Coords,x
    POKE @printAt42Coords+1,y
END SUB

...

printAt42Coords:

...

I don't know what type of variable printAt42Coords is, so can't add a 'dim' statement to define it. I tried defining it as a 'uinteger', but then the compiler complains when it tries to use as a label "error: identifier 'printAt42Coords' is a var, not a function"

Anyone know how to work around this?

Thanks in advance,

This might be a bug, because --explicit was never considered with labels.
I'll check it.
Reply


Messages In This Thread
RE: Print42 library throws error with --explicit option - by boriel - 03-14-2021, 05:12 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)