In modern C, and modern C++:
main
is always either int main()
or int main(int, char*[])
.
- In C89, you have to
return
from main explicitly.
- In C99 and C++, if you don't return explicitly, you implicitly
return 0
.
[(I've checked the C99 standard now and edited this paragraph.)] For your second question, in C99 you must have precisely one of the two main
functions. In C++ the standard says that a program is well-formed if it has a main
function that returns int
, and that every conforming implementation must accept the two listed versions as an entry point (for a "hosted program", e.g. not for the Linux kernel); see 3.6.1. [/edit] To the best of my knowledge, calling conventions are also not part of the standard.
I don't understand your question about memory, but do note that neither C99 nor C++03 have anything but a rudimentary memory model, whereas the new C++0x explicitly adds a memory model in order to enable well-defined concurrent and atomic operations.