Re: Error a:\t_mayn.c:12 illegal return type, found 'int' expected 'void'



On 6 Jul 2005 14:58:20 -0700, "hugo2" <obrhy8@xxxxxxxxx> wrote:

>obrhy, July 6, 2005
>
>Mr. Navia, thank you for your repsonse.
>Nonetheless, I wish to make two comments:
>
>1. In C literature (hardcopy) and in online discussions
> of C, and in the conventions of C compilers,
> main() has all manner of signatures, and what
> a given compiler writer allows or forbids is
> apparently a matter of whim.

An implementation (C compiler) is allowed to support any prototype for
main that it likes, but it is only _required_ to support two. If you
want your code to work on any given C compiler, the main you use must
conform to one of those prototypes. Both of those require main to
return an int.

>
>2. The error message I recieved was in plain english
> but it gave me not a clue as to the nature of my
> offence.
>
>Do you, Jacob, perhaps have a belief that all C programers
>know everything, and if they make a mistake or commit an
>error, that they did it 'on purpose' and therefore deserve
>a pie or piece of pie in the face?
>
>I assure you, sir, the real world is not like that.
>hugo ---
>
Jacob has promised to fix the message. But if you imagine that coming
up with sensible error messages is in any way "easy," especially in a
program such as a compiler, that has to deal sensibly (as it can) with
any random input it might receive, you do indeed live in a world
different from the rest of us.

The code you posted was in error. The error message clearly pointer
to the declaration of "main" as a problem. That's far better than
I've come to expect at least one commercial compiler (targetting an
embedded 8-bit microcontroller) to provide.

You should probably look into lint. PC-lint from Gimpel is an awesome
tool, and it's not very expensive (about US$240). It works with just
about any C compiler around. Splint (www.splint.org) is free, but I
haven't used it much.

In any case, the purpose of lint is to provide error messages.
PC-lint, at least, comes with a tremendous user manual that explains
each error message in detail. You can lear a lot about your code and
the C programming language by taking the time to understand what lint
is telling you.

Regards,

-=Dave
--
Change is inevitable, progress is not.
.



Relevant Pages

  • understanding segmentation faults
    ... Is "segmentation fault" an error message that is issued by the operating ... not a problem that the compiler vendors can easily solve. ... technical terminology an "array section"?). ...
    (comp.lang.fortran)
  • Re: xPC target w/ Matlab 2009a - unable to build model
    ... The error message makes me believe that there is some compiler environment/path issue on the PC you are working on. ... When you do a mex -setup are you able to see the Watcom 1.7 compiler? ... Setting environment for using Microsoft Visual Studio 2008 ...
    (comp.soft-sys.matlab)
  • Re: operator function
    ... >> of them have anything to do with what the error message seems ... Setting (int h, int m, int s, int TT) ... Now the compiler knows, that it is safe to use that function on a const ... >> operator returns a Setting object. ...
    (alt.comp.lang.learn.c-cpp)
  • c89 problem w/ irrhfsu
    ... i've got a lot of experience setting up and configuring OMVS but not ... by means of the c89 compiler, inside the OMVS environment, (this is ... and i received the following error message: ...
    (bit.listserv.ibm-main)
  • Re: ILC2005: McCarthy denounces Common Lisp, "Lisp", XML, and Rahul
    ... SU-AI and run Lisp 1.6 or UCI-Lisp. ... kernel of an operating system or a compiler etc. ... have the power of Lisp instead of only C to manipulate those lists. ... apply so the error message doesn't occur. ...
    (comp.lang.lisp)