Print42 library throws error with --explicit option - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16) +---- Thread: Print42 library throws error with --explicit option (/showthread.php?tid=1042) |
Print42 library throws error with --explicit option - georgeo - 03-13-2021 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" 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) 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, RE: Print42 library throws error with --explicit option - boriel - 03-14-2021 (03-13-2021, 10:59 AM)georgeo Wrote: Hi everyone, This might be a bug, because --explicit was never considered with labels. I'll check it. RE: Print42 library throws error with --explicit option - boriel - 03-23-2021 (03-14-2021, 05:12 PM)boriel Wrote:(03-13-2021, 10:59 AM)georgeo Wrote: Hi everyone, Ok, I think I've fixed it. Please, download this new beta version and tell me if it works (with --explicit): http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta13.tar.gz http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta13.zip http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta13-win32.zip http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta13-linux64.tar.gz http://www.boriel.com/files/zxb/zxbasic-1.15.0-beta13-macos.tar.gz Thx RE: Print42 library throws error with --explicit option - georgeo - 03-24-2021 Hi Boriel, Thanks. I'll give it a try tomorrow, and report back. Speak to you soon, Georgeo. RE: Print42 library throws error with --explicit option - georgeo - 03-25-2021 Hi Boriel, Based on a quick test, the fix looks to work. I no longer see errors when I reference labels from within my code, plus the print42 library doesn't cause an error. Thanks again. Looks good, Georgeo. RE: Print42 library throws error with --explicit option - boriel - 03-25-2021 (03-25-2021, 06:02 PM)georgeo Wrote: Hi Boriel, Good to know! |