Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C Moderated > Re: return type...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 11 of 13 Topic 1059 of 1133
Post > Topic >>

Re: return types with conditional

by Keith Thompson <kst-u@[EMAIL PROTECTED] > Mar 20, 2008 at 01:09 AM

Andre Poenitz <poenitz@[EMAIL PROTECTED]
> writes:
> Allan Adler <ara@[EMAIL PROTECTED]
> wrote:
>> Suppose the program is:
>> main() { fn1(); if (debug == 0) fn2();}
>> where fn2() returns int and fn1() returns int*. Since main is
implicitly
>> being declared as returning int, is there a possible problem here?
>
> There is no problem. In both cases (debug == 0, and debug != 0)
> main() will return 0 independently of what fn1() and possibly fn2()
> returned. This implicit 'return 0;'is, btw, a special rule for main().
> You can't rely on that in general.
[...]

And it's a new rule in C99.  In pre-C99 implementations, falling off
the end of main() returns an undefined status to the environment.
(IMHO depending on it even in C99 is poor style.)

-- 
Keith Thompson (The_Other_Keith) <kst-u@[EMAIL PROTECTED]
>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
-- 
comp.lang.c.moderated - moderation address: clcm@[EMAIL PROTECTED]
 -- you must
have an appropriate newsgroups line in your header for your mail to be
seen,
or the newsgroup name in square brackets in the subject line.  Sorry.
 




 13 Posts in Topic:
return types with conditional
Allan Adler <ara@[EMAI  2008-03-08 12:21:45 
Re: return types with conditional
Keith Thompson <kst-u@  2008-03-17 15:19:07 
Re: return types with conditional
gordonb.v71k9@[EMAIL PROT  2008-03-17 15:19:10 
Re: return types with conditional
=?ISO-8859-1?Q?Hans-Bernh  2008-03-17 15:20:17 
Re: return types with conditional
Jonathan Leffler <jlef  2008-03-17 15:21:09 
Re: return types with conditional
Thomas Richter <thor@[  2008-03-17 15:21:37 
Re: return types with conditional
Francis Glassborow <fr  2008-03-17 15:21:46 
Re: return types with conditional
Jack Klein <jackklein@  2008-03-17 15:21:48 
Re: return types with conditional
Barry Schwarz <schwarz  2008-03-17 15:21:55 
Re: return types with conditional
Andre Poenitz <poenitz  2008-03-17 15:22:28 
Re: return types with conditional
Keith Thompson <kst-u@  2008-03-20 01:09:19 
Re: return types with conditional
Allan Adler <ara@[EMAI  2008-03-20 01:09:46 
Re: return types with conditional
Kenneth Brody <kenbrod  2008-03-20 15:57:19 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 2:14:50 CDT 2008.