4 ms·
Is it strange that C++ is able to do this but C itself cannot? Sometimes I hear the argument that "C is lower level" and their is the idiom that "C++ is C but b
by ddtaylor 9y ago
Is it strange that C++ is able to do this but C itself cannot? Sometimes I hear the argument that "C is lower level" and their is the idiom that "C++ is C but better" (not that I believe these are true)
- Retric 9y agoIt's somewhat misleading when they say the C++ code runs before main. What's going on is after the same initialization steps the first code of your program is executed. C and C++ have different syntax for what that code is, but it's pure semantics as far as the computer is concerned and C++ gives you zero extra power.
- kbumsik 9y agoIt is certainly possible to do this with C by editing a startup code. In embedded system, a source code of startup is provided and exposed by manufacturer's SDK so it is quite straightforward to do this. Besides that, I can't see much difference between doing something before main() and just putting some code on the very top of main().