linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ron Michael Khu <ronkhu@ntsp.nec.co.jp>
To: Steve Graegert <graegerts@gmail.com>
Cc: Ankit Jain <ankitjain1580@yahoo.com>,
	Glynn Clements <glynn@gclements.plus.com>,
	linux-c-programming@vger.kernel.org
Subject: Re: variable length function
Date: Thu, 16 Jun 2005 01:22:17 +0800	[thread overview]
Message-ID: <42B063C9.40306@hq.ntsp.nec.co.jp> (raw)
In-Reply-To: <6a00c8d505061509263ca76278@mail.gmail.com>

Mr Ankit Jain,

u can verify all these "main return value" ambiguity
by making a simple script file that would print the return value
of the last app executed. In bash u could simply use "echo $?" on the 
command line.

So in dos mode, Perhaps u could make use of  "echo %errorlevel%" on the 
dos prompt

with these simple shell commands, u will then be able to see for urself 
if a
void-valued main would implicity return an int or not...

-ron


Steve Graegert wrote:

>On 6/15/05, Ankit Jain <ankitjain1580@yahoo.com> wrote:
>  
>
>>hi
>>    
>>
>
>[snip]
>
>  
>
>>if i write the same module in it then it takes void as
>>the default return type...........?
>>    
>>
>
>No it does not.  When specifying no return type int is returned
>implicitly.  Under Windows, even if main is void-valued, the exit
>code, whatever value it may have, is converted to int.
>
>  
>
>>--- Glynn Clements <glynn@gclements.plus.com> wrote:
>>
>>    
>>
>>>Ankit Jain wrote:
>>>
>>>      
>>>
>>>>Well then i am just trying to clear my concept
>>>>        
>>>>
>>>again.
>>>      
>>>
>>>>main()
>>>>{
>>>>
>>>>         printf("This is main");
>>>>
>>>>}
>>>>
>>>>now this simple function main according to this
>>>>discussion will return a int value.......Am i
>>>>right....
>>>>        
>>>>
>>>Correct.
>>>
>>>      
>>>
>>>>but is it true with any compiler?
>>>>        
>>>>
>>>It's true for any compiler which supports pre-ANSI C
>>>(aka "K&R C").
>>>ANSI C requires the return type to be specified.
>>>
>>>      
>>>
>>>>another thing........... if it returns a int value
>>>>        
>>>>
>>>and
>>>      
>>>
>>>>we have not returned any value
>>>>        
>>>>
>>>explicitly.........then
>>>      
>>>
>>>>what is the value returned ....as far as i know
>>>>        
>>>>
>>>its a
>>>      
>>>
>>>>non-zero value. but then what will that mean.....?
>>>>        
>>>>
>>>It's an unspecified value. It could be any "int"
>>>value, including
>>>zero. As there is only one zero but many more
>>>non-zero values, it
>>>probably won't be zero, but it isn't guaranteed.
>>>
>>>Hopefully the compiler will issue a warning in this
>>>situation.
>>>
>>>--
>>>Glynn Clements <glynn@gclements.plus.com>
>>>
>>>      
>>>
>-
>To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
>the body of a message to majordomo@vger.kernel.org
>More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
>  
>



  reply	other threads:[~2005-06-15 17:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-14 17:43 variable length function Ankit Jain
2005-06-14 19:14 ` Steve Graegert
2005-06-15  2:23   ` Glynn Clements
2005-06-15  6:33     ` Steve Graegert
2005-06-15  8:36       ` Ankit Jain
2005-06-15  9:08         ` Steve Graegert
2005-06-15 11:33         ` Glynn Clements
2005-06-15 15:59           ` Ankit Jain
2005-06-15 16:26             ` Steve Graegert
2005-06-15 17:22               ` Ron Michael Khu [this message]
2005-06-16  2:31           ` Rajkumar Andrews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42B063C9.40306@hq.ntsp.nec.co.jp \
    --to=ronkhu@ntsp.nec.co.jp \
    --cc=ankitjain1580@yahoo.com \
    --cc=glynn@gclements.plus.com \
    --cc=graegerts@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).