Re:What happens before main() is executed in C and why is it...
by jononor on Friday May 04, 2018 @01:22PM
(#16996321)
The linker script is what runs the global constructors in C++. Nothing preventing using a custom linker script in C to call some `premain()` function.
[ Parent
| on HN ]
Re:What happens before main() is executed in C and why is it...
by baruch on Friday May 04, 2018 @01:28PM
(#16996381)
At least in gcc you can use constructor attribute to run code before main. I've seen this used to initialize modules and create a dependency tree of modules to initialize before main even starts.