#Pragma Warning/Error - hidden gems

In working through debugging an oddity, I bumped into the #Pragma Warning and #Pragma Error features. Over 18 years of working with Xojo (and previous brand names), I’d never noticed this.

What a great way to identify things you’re questioning or unsure of for Debug and Analysis runs.

Note that this will remind you to work on something without the possibility of releasing it:

#if DebugBuild then
  #pragma warning "Finish this!"
#else
  #pragma error "You didn't finish this!!!"
#endif

You can run this code through the IDE but cannot build it.

5 Likes

This is like what I’m doing with them now.

For another “hidden gem” did you know that you can limit the scope of a profiling session?

In App.Open just put this line:

StopProfiling

And then surround the code you want to profile with:

StartProfiling
...
StopProfiling

It will only profile the code between those commands (and anything that code calls out to)

10 Likes

Interesting issue in a new project. Using this code

If DebugBuild Then
  #Pragma Warning "## Finish Getting appended tape info or elevating the job."
Else
  #Pragma Error "## Finish Getting appended tape info or elevating the job."
End If

is resulting in the Error flagging the IDE and the Error is being pushed instead of the Warning when debugging. A problem in 2022r2?

Change to

#If DebugBuild
...
#Else
...
#Endif

DUH!

:scream_cat:

Thanks.