Thread overview | ||||||
---|---|---|---|---|---|---|
|
April 06, 2006 Wrong warning (18) | ||||
---|---|---|---|---|
| ||||
Hello, The following code: int f () { throw 10; } int main () { return 0; } produces: Warning 18: implied return of f at closing '}' does not return value Can you please provide a way to disable warnings via #pragma's and push/pop these settings so that warnings are disabled only for some sections of the code ? I wouldn't like to turn off this warning for the entire code. (For example, with Borland, one can write: #pragma option push #pragma warn-par .. #pragma option pop ) Thanks, Adder |
April 06, 2006 Re: Wrong warning (18) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adder | Adder wrote:
> Hello,
>
> The following code:
>
> int f ()
> { throw 10; }
> int main ()
> { return 0; }
>
> produces:
>
> Warning 18: implied return of f at closing '}' does not return value
>
>
> Can you please provide a way to disable warnings via #pragma's
> and push/pop these settings so that warnings are disabled only for some
> sections of the code ? I wouldn't like to turn off this warning for the entire
> code.
>
>
> (For example, with Borland, one can write:
>
> #pragma option push
> #pragma warn-par
> ..
> #pragma option pop
>
> )
An easier way to turn off the warning is to rewrite as:
int f()
{ throw 10;
return 0;
}
|
April 06, 2006 Re: Wrong warning (18) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter Bright |
>An easier way to turn off the warning is to rewrite as:
>int f()
>{ throw 10;
> return 0;
>}
True...
But then the other compiler complains about "Unreachable code in function f" :D However, that can be solved by disabling the warning. For the other compiler.
Thanks !
|
April 06, 2006 Re: Wrong warning (18) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Adder | Adder wrote: >> An easier way to turn off the warning is to rewrite as: ... > But then the other compiler complains about "Unreachable code in function f" :D That's why I hate warnings <g>. |
Copyright © 1999-2021 by the D Language Foundation