0

Can the C _start function be made to call an entry point function other than main?

The reason is I want to have a preprocessor embed additional functions in every C program I compile. The embedded code might provide test functions. Or some special debug features.

When I compile the program I would like to tell _start to call the my_main function instead of main. If command line argument -test is specified, my_main would call the special test functions. Otherwise, my_main calls the actual main function.

walnut
  • 21,629
  • 4
  • 23
  • 59
RockBoro
  • 2,163
  • 2
  • 18
  • 34
  • Like the solution [is right there](https://stackoverflow.com/questions/29694564/what-is-the-use-of-start-in-c). What is funny, even the naming of the `my_main` function is the same. – KamilCuk Sep 03 '19 at 21:21
  • thanks. I saw that yesterday. But then got confused because of a compile error. – RockBoro Sep 03 '19 at 22:10

1 Answers1

1

Yes it may be possible, however it’s all up to the compiler if that feature is supported or not. So you will have to look it up in your compiler manual.

Fredrik
  • 1,389
  • 1
  • 14
  • 32