I am writing a cross platform shared library (.so
in linux and .dll
in windows) using C. Currently when there is a error, library functions returns the proper error code and writes error information into the stderr
. Library functions also emits some information and debug messages to stdout
. This works well for console based clients.
Now this library will have client programs that uses GUI programmed using C++ & wxWidgets. I am wondering what would be the best practices in handling the errors and notifying it? Can a UI application access data coming to stdout
and stderr
on all platforms?
An alternative way I was thinking is the library initialization function initializes a structure which will have function pointers. All the functions on the library will take an instance of this structure and call the function pointers. This way the client can choose where to print the messages.
I am wondering what would be the obvious way to solve this? Any help would be great.