Re: Error a:\t_mayn.c:12 illegal return type, found 'int' expected 'void'
- From: iddw@xxxxxxxxxxx (Dave Hansen)
- Date: Thu, 07 Jul 2005 14:18:06 GMT
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.
.
- Follow-Ups:
- References:
- Prev by Date: Re: Error a:\t_mayn.c:12 illegal return type, found 'int' expected 'void'
- Next by Date: Re: Error a:\t_mayn.c:12 illegal return type, found 'int' expected 'void'
- Previous by thread: Re: Error a:\t_mayn.c:12 illegal return type, found 'int' expected 'void'
- Next by thread: Re: Error a:\t_mayn.c:12 illegal return type, found 'int' expected 'void'
- Index(es):
Relevant Pages
|