#if Targetxxxx

I’ve seen this a lot in posts on the forums and even in code submitted as part of bug reports

If TargetWindows Then
  // Windows only code not excluded from compilation.
End If

The code inside the if will only execute on Windows. However becuase this code is just a normal if it HAS to COMPILE on ALL targets even if the intention is that it only be used on Windows (which it obviously is)

If you intend some code to ONLY be used on Windows you’re better off to use this form

#If TargetWindows Then
  // Declares for example

This code will ONLY exist in a Windows builds and so can ONLY execute on Windows. And, because it will only be used on Windows the compiler will ignore the code inside the #if … #endif on all other platforms so the code doesn’t even have to compile on macOS or Linux (which it would in the first example shown)

Usually when you see the first form you really want the second using #if

Next time you find yourself writing

if Target

reconsider if you really should be using #if instead