Page 1 of 1
CompilerWarning
Posted: Tue Jul 31, 2012 2:25 am
by kenmo
PureBasic already has
CompilerError, which allows us to force an error if the person compiling should be alerted of something. It would be nice if we could force a CompilerWarning too, which would not prevent compilation, but it would still present an obvious warning to the user that something is wrong or important.
It would be similar to the warnings that appear when a resource fails to load:
Code: Select all
If LoadImage(0, "doesNotExist.bmp")
Debug "A warning should appear in the IDE."
EndIf
Also, this is a very minor punctuation request, but I wish the period "." was not automatically added to our CompilerError strings, such as:
Re: CompilerWarning
Posted: Tue Jul 31, 2012 6:11 am
by Shield
+1, good points.
Re: CompilerWarning
Posted: Tue Jul 31, 2012 6:49 am
by ts-soft
WorkAround (crossplattform)
Code: Select all
CompilerIf #PB_Compiler_Debugger
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Windows
Import ""
PB_DEBUGGER_SendWarning(Message.p-ascii)
EndImport
CompilerDefault
ImportC ""
PB_DEBUGGER_SendWarning(Message.p-ascii)
EndImport
CompilerEndSelect
CompilerEndIf
Macro CompilerWarning(error)
CompilerIf #PB_Compiler_Debugger
PB_DEBUGGER_SendWarning(error)
CompilerEndIf
EndMacro
CompilerWarning("A warning should appear in the IDE.")
Re: CompilerWarning
Posted: Wed Aug 01, 2012 1:18 am
by kenmo
That's a useful tip, thank you.
I always see people posting these Import "" tips and I don't know how they know about them! Are they documented somewhere?
Re: CompilerWarning
Posted: Wed Aug 01, 2012 9:27 am
by ts-soft
To import a function from a lib, that is imported, no name for the lib required.
make sure, the lib is imported!
Re: CompilerWarning
Posted: Wed Aug 01, 2012 10:37 am
by wilbert
ts-soft wrote:WorkAround (crossplattform)
It's not entirely cross platform.
For OS X you need to use
ImportC .
Re: CompilerWarning
Posted: Wed Aug 01, 2012 11:06 am
by ts-soft
wilbert wrote:It's not entirely cross platform.
For OS X you need to use ImportC .
Thx, changed
(i can't make any test on macos)
Re: CompilerWarning
Posted: Wed Aug 01, 2012 11:12 am
by wilbert
ts-soft wrote:Thx, changed

It's working fine now on OS X

Re: CompilerWarning
Posted: Mon Nov 16, 2015 6:34 am
by Little John
Done.
I just found out that this has been added in PB 5.40 LTS (tested with the Windows versions).
I can't see where it is documented, though.
Re: CompilerWarning
Posted: Mon Nov 16, 2015 1:58 pm
by StarBootics
Little John wrote:Done.
I just found out that this has been added in PB 5.40 LTS (tested with the Windows versions).
Also work on Linux (Ubuntu Gnome).
Just nice !
Best regards
StarBootics
Re: CompilerWarning
Posted: Mon Nov 16, 2015 8:15 pm
by freak
Please note that what was implemented here is a compiler warning. This means the warning is triggered at compile-time and you have to use things like CompilerIf if you want to show it conditionally. What ts-soft posted is code to trigger a debugger warning. This warning is issued by the debugger at run-time, and it will only show if the statement is actually executed (so you can show it conditionally using a regular if). There seems to be some confusion between the two at times.
For completeness, i just added two functions DebuggerError(Message$) and DebuggerWarning(Message$) to trigger debugger errors (in essence what ts-soft showed as an official function). This will be in v5.50.
Re: CompilerWarning
Posted: Tue Nov 17, 2015 12:14 pm
by NicTheQuick
Nice!