I’d always thought #pragma was a compile time thing
Like
#pragma warning "some warning message"
But apparently one isn’t
#If debugBuild
If isNormsMachine Then // isNormsMachine determines, at runtime, if this is MY machine or not
#Pragma BreakOnExceptions True
else
#Pragma BreakOnExceptions False
End If
#EndIf
and sure enough on my machine this turns break on exceptions ON in debug builds
and turns it off on everyone else’ machine
At first glance I’d agree. But BreakOnExceptions only makes sense in a DebugBuild and wouldn’t do anything in a regular build, right? So I understand this pragma as a way to control the debugger, not the compiler.
Yes
Thats why its buried inside #I fDebugBuild which is probably unnecessary
its more “self documenting” that this code inside the #if debugbuild will only happen in debug builds
The strange part is that the #pragma is a runtime thing not a “compiler directive”
Its not like nil object checking where we can turn it off and the compiler wont insert those checks or bunds checking etc
Those all influence how the compiler emits code - whether it includes stack over flow checks or not , nil object checks or not
And trying to set them true / false WHILE the apps runs has no impact
Once the code is generated thats it and that IS how it will run
This one doesnt tell the compiler to do anything
It tells the runtime whether or not to, at runtime, break on exceptions or not
And I’ve done a little sample where I can flip it at runtime and it will turn break on exceptions on & off
Yes, I understand how #pragma BreakOnExceptions differs from the other pragmas. But I also see the usefulness of the different behaviour (and I make use of it quite often).
OTOH if Xojo were more consistent, they should have introduced something like #debugger BreakOnExceptions. But hey, they’ve proven to like renaming things, so maybe there’s still hope