Re: [Lazarus] Warning: Unreachable code. Why?
> 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. Ah, now I see. > You would be just as effective using > > {$IFDEF WINDOWS} >Exit; > {$ENDIF} > Yep. Thanks for the explanation! Bart ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus
Re: [Lazarus] Warning: Unreachable code. Why?
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. ___ Lazarus mailing list Lazarus@lazarus.freepascal.org http://www.lazarus.freepascal.org/mailman/listinfo/lazarus