2

How is it possible for certain C++ & C# frameworks to run without requiring the users to implement a main function or class?

For example; in MVVM Cross you implement your MvxApplication and everything goes from there. In wxWidgets you implement your wxApp.

Do the frameworks implement main in their API's or do they completely bypass it? Is there a term for a framework design that abstracts away main? What is the benefit of this design?

sazr
  • 24,984
  • 66
  • 194
  • 362
  • If you start debugging step by step (F11 in Visual Studio) the execution should stop right at the start of the main function, no matter how well is hidden. Unless ofc if C# method has [DebuggerStepThroughAttribute](https://msdn.microsoft.com/en-us/library/system.diagnostics.debuggerstepthroughattribute.aspx), in which case you can override it in [debugger settings](http://stackoverflow.com/q/1099949/395718). – Dialecticus Dec 24 '15 at 12:42

2 Answers2

1

In wxWidgets case you still get main() or WinMain(), it is just hidden inside the wxIMPLEMENT_APP() macro. The main benefit is that you don't have to use conditional compilation in your own code to define WinMain() under Windows and main() elsewhere (in the past, there used to be other platforms which used something other than main(), but I believe they're all extinct by now).

VZ.
  • 21,740
  • 3
  • 39
  • 42
0

There has to be a main. So these frameworks must provide there own main and then call their framework specific main (e.g. MvXApplication).

The reason they do this is because the framework must require certain starting/ending function calls or actions to take place before/after calling client code. And these actions are probably too complicated or too numerous to require client code to do.

I don't know of a term or name for this.

Anon Mail
  • 4,660
  • 1
  • 18
  • 21