[A83] Re: C(++) programming
[Prev][Next][Index][Thread]
[A83] Re: C(++) programming
> > wrong, you can also have a main function like this: void main();
> > then you won't find "return" in the main function.
>
> You certainly can define the main function that way, but the C startup
> code generally would expect an integer to be returned, so you should at
> least get a warning when trying to compile that (GCC gives one).
ok. but when you think of embedded platforms without an OS (like some 8051)
it doesn't make any sense to return a value in main so void main() is used.
> Also, it is quite possible to use return in a void function; in this case
> it simply exits the function at that point without giving a return value.
ok, this would work for sure. i didn't tinkt of this way because i use
exit() most of the time.
> > you can never call main as far as i know! so a = main(); would be
impossible
> > because main is not a standard function.
>
> It is non-standard in that it is the the main function called by the
> startup code to run your program, but other than that, I don't know of
> anything really unique about it.
what about returning a value to the OS (if there is one)? is this possible
in other functions too?
> Calling main from inside the program has
> worked every time I tried it, though I don't think that it is useful to do
> so very often.
ok. i tried it. it works. but i really have to say i never had an
application which calls main from an other function.
Follow-Ups:
References: