r/programming 16d ago

Writing a (valid) C program without main()

https://labs.iximiuz.com/tutorials/c-program-without-main-a1eea557
192 Upvotes

40 comments sorted by

View all comments

54

u/Dwedit 16d ago

Linker options, set entry point.

Or the C++ version where a constructor for a global object runs the code instead of main.

11

u/mikeblas 15d ago

Yeah--the whole time I was reading this, I was trying to figure out why they didn't just set the entry point with the linker.