public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: warning: return type of main is not int
@ 1998-01-16 19:49 Mike Stump
  1998-01-19  2:30 ` Alexandre Oliva
  0 siblings, 1 reply; 7+ messages in thread
From: Mike Stump @ 1998-01-16 19:49 UTC (permalink / raw)
  To: egcs, jinbo21

> Date: Fri, 16 Jan 1998 10:52:41 +0900 (KST)
> From: Byeong-ryeol Kim <jinbo21@soback.kornet.nm.kr>
> To: egcs@cygnus.com

>  I often met this warning after installing egcs on rh 5.0.
>  Is this harmless?
> void main(int argc, char *argv[])

This is reasonably safe, but wrong for C++.  The return type should be
int not void.  Why bother asking us, it takes less time to fix the
code as the compiler instructs.  return 0, if you don't know of a
better value to return.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: warning: return type of main is not int
  1998-01-16 19:49 warning: return type of main is not int Mike Stump
@ 1998-01-19  2:30 ` Alexandre Oliva
  0 siblings, 0 replies; 7+ messages in thread
From: Alexandre Oliva @ 1998-01-19  2:30 UTC (permalink / raw)
  To: Mike Stump; +Cc: egcs, jinbo21

Mike Stump writes:

>> From: Byeong-ryeol Kim <jinbo21@soback.kornet.nm.kr>

>> I often met this warning after installing egcs on rh 5.0.
>> Is this harmless?
>> void main(int argc, char *argv[])

> return 0, if you don't know of a
> better value to return.

In fact, you don't even have to bother about returning anything, since
falling off function `main' is equivalent to returning 0, as defined
in [basic.start.main]/5

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: warning: return type of main is not int
  1998-01-16  1:51 Byeong-ryeol Kim
  1998-01-16 19:49 ` Joe Buck
@ 1998-01-17  1:40 ` Joseph H. Buehler
  1 sibling, 0 replies; 7+ messages in thread
From: Joseph H. Buehler @ 1998-01-17  1:40 UTC (permalink / raw)
  To: egcs

Byeong-ryeol Kim <jinbo21@soback.kornet.nm.kr> writes:

>  I often met this warning after installing egcs on rh 5.0.
>  Is this harmless?
>  The typical code is as follows:
> ....
> void main(int argc, char *argv[])
> {

That's illegal C/C++, I believe.  The operating system expects an
integer return value from main().

Joe Buehler

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: warning: return type of main is not int
  1998-01-16 19:49 ` Joe Buck
@ 1998-01-16 20:09   ` Byeong-ryeol Kim
  1998-01-16 20:09     ` Joe Buck
  0 siblings, 1 reply; 7+ messages in thread
From: Byeong-ryeol Kim @ 1998-01-16 20:09 UTC (permalink / raw)
  To: Joe Buck; +Cc: egcs

On Fri, 16 Jan 1998, Joe Buck wrote:
...
> The C++ language standard says that main returns int.  The compiler
> is warning you that what you are typing is not legal C++.
> 
> > void main(int argc, char *argv[])
...
 I'm actually a beginner.
 If so, how can I fix it?

 "Where there is a will, there is a way."  jinbo21@soback.kornet.nm.kr 
                                           kbeyl@kids.kotel.co.kr      
  For the future of you and me!            hitel: jinbo21


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: warning: return type of main is not int
  1998-01-16 20:09   ` Byeong-ryeol Kim
@ 1998-01-16 20:09     ` Joe Buck
  0 siblings, 0 replies; 7+ messages in thread
From: Joe Buck @ 1998-01-16 20:09 UTC (permalink / raw)
  To: jinbo21; +Cc: jbuck, egcs

> > The C++ language standard says that main returns int.  The compiler
> > is warning you that what you are typing is not legal C++.
> > 
> > > void main(int argc, char *argv[])
> ...
>  I'm actually a beginner.
>  If so, how can I fix it?

I'll answer this one, but *please* don't use the egcs mailing list to
ask beginner C++ questions.  Try a C++ book or comp.lang.c++.moderated
(I won't advise the unmoderated comp.lang.c++ to anyone).

Just change the "void" to "int".



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: warning: return type of main is not int
  1998-01-16  1:51 Byeong-ryeol Kim
@ 1998-01-16 19:49 ` Joe Buck
  1998-01-16 20:09   ` Byeong-ryeol Kim
  1998-01-17  1:40 ` Joseph H. Buehler
  1 sibling, 1 reply; 7+ messages in thread
From: Joe Buck @ 1998-01-16 19:49 UTC (permalink / raw)
  To: jinbo21; +Cc: egcs

>  I often met this warning after installing egcs on rh 5.0.
>  Is this harmless?

The C++ language standard says that main returns int.  The compiler
is warning you that what you are typing is not legal C++.

> void main(int argc, char *argv[])

^ permalink raw reply	[flat|nested] 7+ messages in thread

* warning: return type of main is not int
@ 1998-01-16  1:51 Byeong-ryeol Kim
  1998-01-16 19:49 ` Joe Buck
  1998-01-17  1:40 ` Joseph H. Buehler
  0 siblings, 2 replies; 7+ messages in thread
From: Byeong-ryeol Kim @ 1998-01-16  1:51 UTC (permalink / raw)
  To: egcs

 I often met this warning after installing egcs on rh 5.0.
 Is this harmless?
 The typical code is as follows:
....
void main(int argc, char *argv[])
{
    int sock, i;
    
    if ((argc > 1) && (strcmp(argv[1], "-v") == 0))
        printf("%s", version);
    
    sock = i365_probe();
    for (i = 0; i < sock; i++) {
        printf("Socket %d:\n", i);
        dump_sock(i);
    }
}
...

 "Where there is a will, there is a way."  jinbo21@soback.kornet.nm.kr 
                                           kbeyl@kids.kotel.co.kr      
  For the future of you and me!            hitel: jinbo21


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1998-01-19  2:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-01-16 19:49 warning: return type of main is not int Mike Stump
1998-01-19  2:30 ` Alexandre Oliva
  -- strict thread matches above, loose matches on Subject: below --
1998-01-16  1:51 Byeong-ryeol Kim
1998-01-16 19:49 ` Joe Buck
1998-01-16 20:09   ` Byeong-ryeol Kim
1998-01-16 20:09     ` Joe Buck
1998-01-17  1:40 ` Joseph H. Buehler

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 read-only IMAP folder(s) and NNTP newsgroup(s).