[Lazarus] Warning: Unreachable code. Why?
Brad Campbell
brad at wasp.net.au
Fri Dec 5 19:51:41 CET 2008
Bart wrote:
> In my browserdetection code I have this:
>
> const
> OS_HAS_DEFAULT_BROWSER = {$IFDEF WINDOWS}True{$ELSE}False{$ENDIF};
>
> When I compile my program I get this warning:
> "browserdetection.pp(187,34) Warning: unreachable code"
>
> line 187 ->
> if OS_HAS_DEFAULT_BROWSER then Exit;
> (the cursor then blinks on the E in Exit (position 34))
>
> Why is this?
Because if OS_HAS_DEFAULT_BROWSER = false then the compiler will optimise the if call away (as it
can never actually execute) and the "Exit" can never be reached.
You would be just as effective using
{$IFDEF WINDOWS}
Exit;
{$ENDIF}
Brad
--
Dolphins are so intelligent that within a few weeks they can
train Americans to stand at the edge of the pool and throw them
fish.
More information about the Lazarus
mailing list