Wednesday 15 January 2014

c++ - Cross-platform error message -


When my C ++ cross-platform (Windows, Linux, Mac) fails to initialize the OpenGL application,

I The user wants to display an error message that knows what's wrong.

My thoughts are:

  1. Write errors in std :: cerr
    • Problem: Shell not displayed on Linux < Li> Problem: The console is always displayed on Windows, even if it is not necessary (Consolidated as a console application)
    • Use the GUI library
        < Li> Problem: Overclock, because everything will be displayed using OpenGL. Platform-specific implementation and #ifdef
        • Problem: I did not want to mess with the original API, and potentially

          How to solve it?

          The GUI solution is actually a good but the problem is actually that you will need another dependency, Unless that ... ...

          ... is the code platform of only one function for each, which will report the error using the GUI code for each platform.

          You will apply one of these error function reports only to your primary platform, then through porting, write other versions if you are already working directly with all platforms, then all Make one for platforms and go with it.

          Because it is only for reporting a message, it should not be difficult, too long or too problematic. / P>

          Just follow the kiss principle.

          (Note: The problem occurs when the problem occurs, which will definitely be more secure) instead of the next startup can be displayed


          It is said that in future you may need more complex error reporting systems. In this case, it is important to develop your error report code as a separate project, which should have its reliance and start with any problem with the main project (the way it communicates). In this case, it is okay to have other dependencies like QT (though it is heavy ...) or wxWidgets (also of type) or GTK (my experience with it is not positive but it is okay for simple things). A GUI framework designed to be lightweight and simple is FLTK, so it can be simple and light to sit next to your application.

No comments:

Post a Comment