Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compiler Returncode
#1
Hi Boriel, I have noticed that your compiler exits with returncode Zero if no errors was found, One if Errors found, but also One if a warning was generated, and the compilation was otherwise successfull. Can you change this?
0=No errors
1=Warnings, compilation was OK.
2=Error, compilation failed
Or:
0=No Errors or just warnings
1=Error, compilation failed.
The BorIDE does now mark Warning and error lines. It can start the emulator after compilation, but if a warning was issued, it still missinterprets it as compilation fail.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply
#2
I agree, since this is the most common scheme, Warnings will return a 0 error code.
If the programmer wants a non-zero error code, he/she might use a compiler flag like -Werror (which transforms warning into errors) or the like.
I'm also preparing a flag for enabling/disabling specific warnings in some places in the source code (e.g. disabling "Function is never called" warning temporarily, etc...).
Reply
#3
This would be great! Thank you vey much. I welcome both functions.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply
#4
LCD Wrote:This would be great! Thank you vey much. I welcome both functions.
I've just checked the compiler for this, and it *already* behaves as expected: Return error code 0 (OK) when there're only warnings. :?:
Can you check it on your computer? Or tell me exactly what kind of warning are you getting? Because here, warnings do not count for error codes (as expected).
Reply
#5
boriel Wrote:
LCD Wrote:This would be great! Thank you vey much. I welcome both functions.
I've just checked the compiler for this, and it *already* behaves as expected: Return error code 0 (OK) when there're only warnings. :?:
Can you check it on your computer? Or tell me exactly what kind of warning are you getting? Because here, warnings do not count for error codes (as expected).

Cannot find the warnings at moment becaues I corrected all the bugs in my source. It was maybe something with loss of precision. If I run again on such a problem, I will post it here. in this thread.
Edit: Got one:
warning: Variable 'txtadr' declared as 'float'. In the line:
Code:
poke uinteger @PropPrintTxtadr,txtadr
It is a warning, not a error...
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply
#6
LCD Wrote:warning: Variable 'txtadr' declared as 'float'. In the line:
Code:
poke uinteger @PropPrintTxtadr,txtadr
It is a warning, not a error...
Compiling the following code:
Code:
DIM PropPrintTxtadr as Uinteger

POKE Uinteger  @PropPrintTxtadr,txtadr
[/code]
I get the same warning, and exit code is 0 (no errors). :?:
Reply
#7
Strange...
Please try this:
Code:
poke uinteger @PropPrintTxtadr,txtadr
end
PropPrintTxtadr:
asm
text_addr:
   DEFW test_text ; Addr of text
end asm
BorIDE Diagnosis displays following text:
02:23:10 -> Compilation starts(8 Lines)
02:23:10 -> "C:\Program Files\Boriel Tm\ZX Basic Compiler\zxb.exe" "D:\Backup von C Neu\Coding\Retro-X (Sources)\sources\temp.bor" -S 24200 -t -B -a -o "D:\Backup von C Neu\Coding\Retro-X (Sources)\sources\Boride_Files\test16".tap -O 0

02:23:11 -> Exit code: 1
02:23:11 -> temp.bor:1: warning: Variable 'txtadr' declared as 'float'. Compilation failed
02:23:11 -> Compilation time: 672ms

I use ZX Basic Compiler version: zxb.exe 1.2.6-r1571
if you delete the @ character, it is even stranger...
02:25:38 -> Compilation starts(8 Lines)
02:25:38 -> "C:\Program Files\Boriel Tm\ZX Basic Compiler\zxb.exe" "D:\Backup von C Neu\Coding\Retro-X (Sources)\sources\temp.bor" -S 24200 -t -B -a -o "D:\Backup von C Neu\Coding\Retro-X (Sources)\sources\Boride_Files\test16".tap -O 0

02:25:38 -> Exit code: 1
02:25:38 -> temp.bor:1: warning: Variable 'PropPrintTxtadr' declared as 'float'. Compilation failed
02:25:38 -> Compilation time: 547ms
But without the Label and ASM code it does return the code 0...
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply
#8
I can't see what's wrong with the compiler throwing up an error there? What's the problem?


poke uinteger @PropPrintTxtadr,txtadr

Has an issue - what is txtadr? Quite reasonably, the compiler doesn't know. So it assumes it's a float, and probably calls it zero. And warns you:

02:23:11 -> temp.bor:1: warning: Variable 'txtadr' declared as 'float'. Compilation failed

If you go with:

poke uinteger PropPrintTxtadr,txtadr

Well, now the compiler has two pieces of text that aren't numbers or defined variables. So it throws a fit about that too. It doesn't know what PropPrintTxtadr should be, so it defines a float, and tries to carry on. But it does warn you. (@text must refer to a label. Just text means it's a variable).

The problem is then, that if it's defined as a variable by the compiler, since it didn't know what to do with it, when it hits the label it REALLY throws a fit, because it's already defined PropPrintTxtadr...

I'm a little confused - Am I missing something here? It seems pretty clear cut to me.
(Though, Boriel, if you are listening, I actually strongly DISLIKE this behavior - where something unknown is made into a variable automatically. I'd MUCH prefer the compiler to stop with an error, there. One mistyped variable name and the code still compiles; but obviously doesn't work... I'd rather know about it in no uncertain terms! Can we at least have a compiler option that makes it stop instead of warn if something isn't defined with a DIM or a LET already?)
Reply
#9
britlion Wrote:I can't see what's wrong with the compiler throwing up an error there? What's the problem?


poke uinteger @PropPrintTxtadr,txtadr

Has an issue - what is txtadr? Quite reasonably, the compiler doesn't know. So it assumes it's a float, and probably calls it zero. And warns you:

02:23:11 -> temp.bor:1: warning: Variable 'txtadr' declared as 'float'. Compilation failed

If you go with:

poke uinteger PropPrintTxtadr,txtadr

Well, now the compiler has two pieces of text that aren't numbers or defined variables. So it throws a fit about that too. It doesn't know what PropPrintTxtadr should be, so it defines a float, and tries to carry on. But it does warn you. (@text must refer to a label. Just text means it's a variable).

The problem is then, that if it's defined as a variable by the compiler, since it didn't know what to do with it, when it hits the label it REALLY throws a fit, because it's already defined PropPrintTxtadr...
The compiler is *not* failing at all. It's just a merely warning. That was what I was telling LCD previously. According to my tests it is returning a 0 return code (success). I will try on Windows, as the .exe version might be returning something different...

britlion Wrote:I'm a little confused - Am I missing something here? It seems pretty clear cut to me.
(Though, Boriel, if you are listening, I actually strongly DISLIKE this behavior - where something unknown is made into a variable automatically. I'd MUCH prefer the compiler to stop with an error, there. One mistyped variable name and the code still compiles; but obviously doesn't work... I'd rather know about it in no uncertain terms! Can we at least have a compiler option that makes it stop instead of warn if something isn't defined with a DIM or a LET already?)
This is what most compilers do. The warning is a warning because undeclared vars are Float by default with 0 value. So POKE Addr1, aValue (which is the same as Poke Byte Addr1, aValue), translates to POKE 0, 0. Addr1 is converted to Uinterger since a ZX Spectrum Memory address is always a 16 bit integer. Then aValue is converted to the given type to POKE (by default, a byte). If you do POKE @unknown, aValue, then the @unknown type is ok: it's always a memory address (the @operator returns that), but aValue is a float and must be rounded to a byte. That's the warning.

What you should do:
  • Warnings mean "Warning!", "Achtung!". If a program causes warnings, they must be examined one by one to see if they are potential bugs or not.
  • Avoid lower/uppercase mistyping by adding #pragma case_insensitive = TRUE at the beginning of your program (--case-insensitive still not exported to the command line)
  • There will be a flag --Werror (used in GNU gcc among others) that will turn warnings into errors.
  • There will be a flag to enforce variable declarations with --explicit or #pragma explicit (FreeBasic uses #pragma equivalent Option Explicit).
So just wait for the last 2 points, or examine them closely. I'm working slower now in the compiler (writing the Wiki), but all of this will be done.
Reply
#10
The problem is that this is nor a error, but only a warning, The compiler compiles it because warning are just warnings and not errors, but the returncode says, it is a error. It is confusing.
BorIDE uses different colour scheme to display error and warning lines.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply
#11
boriel Wrote:The compiler is *not* failing at all. It's just a merely warning. That was what I was telling LCD previously. According to my tests it is returning a 0 return code (success). I will try on Windows, as the .exe version might be returning something different...

I think there's some confusion. That's exactly what I was saying - there isn't a problem, and all is good!


boriel Wrote:This is what most compilers do. The warning is a warning because undeclared vars are Float by default with 0 value. So POKE Addr1, aValue (which is the same as Poke Byte Addr1, aValue), translates to POKE 0, 0. Addr1 is converted to Uinterger since a ZX Spectrum Memory address is always a 16 bit integer. Then aValue is converted to the given type to POKE (by default, a byte). If you do POKE @unknown, aValue, then the @unknown type is ok: it's always a memory address (the @operator returns that), but aValue is a float and must be rounded to a byte. That's the warning.
Again, I thought I said exactly the same thing. Hmm.

boriel Wrote:[*] Warnings mean "Warning!", "Achtung!". If a program causes warnings, they must be examined one by one to see if they are potential bugs or not.

Two issues here - warnings are easy to miss in something like Tommygun (waiting for BorIDE), because of the limited space - and all you get to read easily is the end "compiled" message.
Secondly, if it's a warning, and bizarrely you decide you're okay with that, you're stuck with that, and all other warnings you're okay with when compiling the whole project forever. Also easy to lose one. Code should be warning free!
(any way to say "this line is okay, don't warn?")

boriel Wrote:[*] Avoid lower/uppercase mistyping by adding #pragma case_insensitive = TRUE at the beginning of your program (--case-insensitive still not exported to the command line)

#pragma is completely undocumented. I know there are some, but apart from the odd snippet like this, I have no idea how to use that. I assume it can come from freebasic....?

boriel Wrote:[*] There will be a flag --Werror (used in GNU gcc among others) that will turn warnings into errors.
[*] There will be a flag to enforce variable declarations with --explicit or #pragma explicit (FreeBasic uses #pragma equivalent Option Explicit).[/list]
So just wait for the last 2 points, or examine them closely. I'm working slower now in the compiler (writing the Wiki), but all of this will be done.


Now you're talking! Those will be very helpful for fixing up projects for someone as typo prone as I am. I miss capitalization all the time.

I also miss brackets, end asm/end function, end sub and end if, as well. Can the compiler explain better why it's stuck, instead of just "unexpected end of file" ?

For example if it said "Unexpected end of file, FOR loop in Line 20 is not closed" that would be an amazing improvement.
Similarly for all the others - asm/IF/SUB/Function/Brackets....
Reply
#12
Just noticed that after some time all compiler warnings starts to fail with exitcode 1.
I was working on a game. Anything was okay: Warnings for unused variables and subs did generate exitcode 0 as expected, but after hours of working, they started to exit with exitcode 1. And if this started, nothing can stop it. Any warning ends with exitcode 1. I don't know what happen. Compiling the same source on a different computer=Exitcode 0.
------------------------------------------------------------
http://lcd-one.da.ru redirector is dead
Visit my http://members.inode.at/838331/index.html home page!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)