Re: [Lazarus] Warning: Unreachable code. Why?

2008-12-06 Thread Bart
> 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?

2008-12-05 Thread Brad Campbell
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


[Lazarus] Warning: Unreachable code. Why?

2008-12-05 Thread Bart
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?

Bart
___
Lazarus mailing list
Lazarus@lazarus.freepascal.org
http://www.lazarus.freepascal.org/mailman/listinfo/lazarus