www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - Wrong warning (18)

↑ ↓ ← Adder <Adder_member pathlink.com> writes:
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
Apr 06 2006
↑ ↓ Walter Bright <newshound digitalmars.com> writes:
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; }
Apr 06 2006
↑ ↓ Adder <Adder_member pathlink.com> writes:
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 !
Apr 06 2006
↑ ↓ → Walter Bright <newshound digitalmars.com> writes:
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>.
Apr 06 2006