home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pipex!warwick!uknet!miclon!nreadwin
- From: nreadwin@micrognosis.co.uk (Neil Readwin)
- Newsgroups: comp.os.vms
- Subject: Re: C problem
- Message-ID: <C1BCpF.GnA@micrognosis.co.uk>
- Date: 23 Jan 93 15:36:51 GMT
- References: <9301201500.AA20662@anon.penet.fi>
- Sender: news@micrognosis.co.uk
- Organization: Micrognosis, a division of CSK(UK) Ltd
- Lines: 40
-
- In article <9301201500.AA20662@anon.penet.fi>, an6034@anon.penet.FI writes:
- |> cc example_1.c
- |> void main(void){ /* begin main */
- |> %CC-W-INVMAINRETVAL, Return value of main function is not an integer type.
- |> At line number 8 in $DISK:EXAMPLE_1.C;24.
-
- |> So am I missing a compiler switch that will make it all ok??
-
- The short answer is ... no, this is not valid C code so you must fix it.
- main *must* return an 'int'.
-
- The long answer is ... both K&R I and ANSI X3.159-1989 define main as a
- function returning 'int' and taking two arguments (an 'int' and an 'array of
- pointer to char'). ANSI also allows main to be defined as taking a 'void'
- argument list. Neither allows main to be a 'void' function since its return
- value may be used by the host system.
-
- The ANSI standard states that a return from the initial call to main is
- equivalent to calling exit() with the argument set to the value returned to
- the caller of main. I cannot find an equivalent statement in K&R (unless
- you count the ambiguous reference to 'return value' in section 7.7) but I
- believe that this was codification of existing practice.
-
- |> I have looked up the error message but it doesn't mean a thing to me.
-
- In this case the second part of the explanation applies - "change the return
- value specification to one of the integer types". The first part is a
- warning about the following mistake ...
-
- struct foo {
- int bar;
- }
-
- main(void) {}
-
- Hope this helps, Neil (who is a little puzzled by the recent burst of
- message from anon.penet.fi).
- --
- Phone: +44 71 815 5283 E-mail: nreadwin@micrognosis.co.uk
- Anything is a cause for sorrow that my mind or body has made
-