I have difficulties understanding the gnome library instructions on how to use GError
in a GTK+ programm written in C. I want to tell the user when the connecting function fails due to the instrument not being detected. I believe this is the sort of error that GError is meant for? What I want to use GError for, is to associate an error message with an error code (DOMAIN_MODULE_ERROR_CODE) that I can then propagate upwards through my program and handle on the top level (with a dialog window if suitable).
I think I understand the propagation of errors via the GError **pointer, but I have difficulties understanding how to set up an error domain and error codes for my own functions. According to library.gnome, I need the following three pieces of code (this is my variation of them), however I am not sure how to link them to gether, i.e. where to put them. At the moment I have them all in a header file and I get a multiple definition error on "pico_comms_error_quark ()".
I basically don't understand how the pieces work together even though I know what they do individually.
Any help would be greatly appreciated, there seems to be very little on this out there on the net.
/* Error domain for picoammeter specific errors */
#define PICO_COMMS_ERROR pico_comms_error_quark ()
* Error quark for picoammeter specific errors
return g_quark_from_static_string ("pico-comms-error-quark");
* Error enum for error codes.
PICO_COMMS_ERROR_NODEVICE, /*< No device found */
PICO_COMMS_ERROR_FAILED /*< No error code for this error */