Guruz said:
hi C gurus do anyone of u know how to write a program in C without
main and still create a executable out of it. Remember, I said no
main() function not in
-->include files
-->libraries
-->no define thisthat main
I mean absolutely no main() atall
You should invest some time in learning to spell the English
language correctly. "u" is a letter. "atall" should be "at all".
Yes, many people know how to write a program in C without a main()
function. I've done it myself on many embedded systems. On my
current project, we don't define "main" so that we can use our
own libraries and start-up code.
Well to start off here one method :
main() is called in C run time object crt0.o.
Perhaps with your compiler, but not with mine.
But if we want to write
crt0.S of our own what r the things we have to do?
Depends greatly on "ur" implementation (compiler). Some compilers
allow you to bypass their run-time library and start up code and
provide "u" w/ the documentation on how "2" do it.
can anyone explain
me whats going on behind this C run time?
Yes, many people can.
In a few words:
There is a bit of code that is executed before the "main" function.
This code initializes the Run-Time library and variables.
Once this is set up the main() function (or "ur" function) can
then be executed. From this point, execution follows your program.
Some implementations also have code which is executed upon the
end or termination of "ur" program.
For more information, research these topics:
Compiler Design & Theory
Operating Systems
"ur" implementation (compiler, linker, etc.)
--
Thomas Matthews
C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq:
http://www.parashift.com/c++-faq-lite
C Faq:
http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.raos.demon.uk/acllc-c++/faq.html
Other sites:
http://www.josuttis.com -- C++ STL Library book