+ 1

Can main() be changed to a different identifier tailored for a specific program? If so then how

main() -> main_entry()

25th Jun 2019, 10:34 PM
Mandla Thabethe
Mandla Thabethe - avatar
7 Answers
+ 5
I don't think so, it's irreplaceable, without it the program won't compile
25th Jun 2019, 10:39 PM
āœ³AsterisKāœ³
āœ³AsterisKāœ³ - avatar
+ 4
which language??? please do specify language while tagging
25th Jun 2019, 10:36 PM
āœ³AsterisKāœ³
āœ³AsterisKāœ³ - avatar
+ 3
What's wrong the following? int main() { return main_entry(); } Many objected oriented programs have main functions that look like: int main() { Application application; return application.run(); } As for your question, there's probably a hacky way to do it in GCC, but there's no standard way to do it and it's not a good idea.
25th Jun 2019, 11:08 PM
Vlad Serbu
Vlad Serbu - avatar
+ 2
Pardon me it's C++
25th Jun 2019, 10:37 PM
Mandla Thabethe
Mandla Thabethe - avatar
+ 2
No but main() can be used as just a wrapper for main_entry() or whatever other primary function name that you like.
26th Jun 2019, 2:56 AM
Sonic
Sonic - avatar
+ 1
It's just that I once came across such on quara but never saw the actual code to do that so I'm on the fence with this one
25th Jun 2019, 10:42 PM
Mandla Thabethe
Mandla Thabethe - avatar
+ 1
But thanks
25th Jun 2019, 10:42 PM
Mandla Thabethe
Mandla Thabethe - avatar