It's been some time now since aside compilererrors compilerwarnings where implemented in PureBasic.
But in my opinion this feature could be much more powerful if it would be used more often in the compiling/debugging-Process.
Some more warnings would lead to cleaner, better understandable and less buggy codes from the PB-Users.

I think most people would like to enable/disable such warning features, so optionality would be good.
Here's a list of what I would like to have added as warnings, feel free to discuss or add your own list.
- Warnings for conditions with missing ProcedureReturn to avoid creating bugs without recognizing:
ExampleHere we have 2 conditions in which there is no defined ProcedureReturn (which is equal to ProcedureReturn 0).Code: Select all
Procedure MyWork(Wert.l) Protected *lbuffer If Wert<$7FFF And Wert>0 *lbuffer=AllocateMemory(10000) If *lbuffer For a=1 To 10000 PokeW(*lbuffer,Wert) *lbuffer+1 Next Else ProcedureReturn 1 EndIf ElseIf Wert>-10 ProcedureReturn -1 EndIf EndProcedure
Of course in some cases, 0 would be correct or at least both could have the same allowed return that could be written in the last line.
But sometimes you have to check inside each condition for the right return. The compiler could help checking this. - It would be nice to be able to turn all Errors created by Enable Explicit into Warnings.
1.)Sometimes you only need a quickcheck what's todo on a code snippet you want to import - Warnings for partly incompatibility of types.
Example:Code: Select all
Procedure.l MyValue(lmyval.l,lmax.l) If lmyval>lmax ProcedureReturn lmax Else ProcedureReturn lmyval EndIf EndProcedure Global wValue.w Global a.l For a=0 To 100000 wValue=MyValue(a,Random(100000)) If a%100=0 Debug wValue EndIf Next
- Warnings for defined but unused variables, that helps to have a cleaner code
I mentioned it here because I think it's useful, even though I already found this thread
where it's also discussed.
It's here just to have my list complete for me. - A CompilerWarning "Message" or DebuggerWarning "Message" Function
There are multiple reasons why it should not be a CompilerWarning or Debug:
0.)It should not stop the debugging or compiling process but return some message like "WARNING: Include xyz.pbi Line 20 Procedure XY(If possible): "Message".
1.)It would be good to have all warnings in one Window (for example the list in the bottom of the PB-IDE-Window) and not in the DebugWindow which in my opinion should be used to Debug variables for the snippet you're currently working on. A good thing would be that you could compile multiple times when having a bug in some of your code and when having that fixed, you could take a look at the Warnings-List
2.)Any programmer could add such warnings to define for example a variables Range for his includes functions.
This could help other programmers to avoid bugs by using the wrong variables or missing a value check before calling a Procedure. - TypeCheck for Procedure Parameters
Especially when working with structures, a typing error is not recognized and can lead to very ugly bugs.
PureBasic knows (at least with EnableExplicit) every variabls type. So, this check should be possible. - Change some Errors to Warnings
Example:That's not a real Error (this is why users are able to click "Play" again) but a warning.Code: Select all
If OpenWindow(1,100,100,200,200,"Hi there") EditorGadget(1,0,0,200,180) ButtonGadget(2,0,180,100,20,"Wrong field") ButtonGadget(3,100,180,100,20,"Right field") Repeat event=WaitWindowEvent() If event=#PB_Event_Gadget Select EventGadget() Case 2 SetGadgetText(0,"That will never be visible") Case 3 SetGadgetText(1,"That's shown") EndSelect EndIf Until event=#PB_Event_CloseWindow EndIf
If wanted, the User should be able to switch that to Warning.
So, what do you think about that?
Best Regards
Franky