Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make other function as entry point other than main() in C

Tags:

c

linux

Each program has a main() and the program execution starts from there. Is it possible to write a program without main()and make another function as the entry point? If so, can any one please tell me how can that be done? I am using Linux?

like image 356
Manu Avatar asked Mar 13 '12 01:03

Manu


People also ask

What is entry point function in C?

What Is an Entry-Point Function? An entry point is a location in code where a transfer of program control (execution) occurs. The main function ( main() ) is the entry point to a C/C++ program and is called when the application starts executing.

Can there be more than one main function in C?

it's not possible in c to have more than 1 main-function. you could use preprocessor directives like "#ifdef" to compile just one main-function at the time.

Where is the entry point of program?

In computer programming, an entry point is the place in a program where the execution of a program begins, and where the program has access to command line arguments.

Which command in GCC changes the function called in place of main in a program *?

If you are on a system that provides GNU Binutils (like Linux), you can use the objcopy command to make an arbitrary function the new entry point. Save this answer.


1 Answers

If you're compiling with gcc, specifying -e <symbol> option will let you change the entry point to a function symbol().

like image 142
George Skoptsov Avatar answered Sep 23 '22 21:09

George Skoptsov