C++ program without main()



The main() function is the starting point for a program execution in Cpp.
Is it possible to run a program without the main() function ? Every time I try it, my compiler shuts down instantaneously.
Just Curious !!
To create a true standalone program you need a main function of some kind as far as I know.
It's not possible to run a program without main, but you CAN do this:

1
2
3
4
5
6
7
8
9
10
11
void program( );
int main( ){
   program( );
   return 0;
}



void program( ){
   // put whatever your program does here
}
I really doubt it. If it's truly possible then I'll write an operating system in HTML.
Sounds sane ..
It is certainly possible. However, if you want to use something other than main(), you'll have to do some assembly programming to replace the C runtime (CRT) that executes your main() function.

This gives the gist of what has to be done: http://sourceware.org/ml/crossgcc/2000-08/msg00010.html

I was getting worried, but I'm not counting ASM.
It is not possible to make a program without the main() function.
A C++ program starts at the main function first. Don't you know curiosity killed the cat!

Also there is a HTML OS out there sort of... Pspwxp, just some pages with flash
See this http://www.youtube.com/watch?v=R4Qq_TXtlZo
Last edited on
I meant a real, bootable OS. And if you open up a program in a text editor, it's HTML.
Topic archived. No new replies allowed.