GTK+
The GIMP Toolkit

General
Introduction
Screenshots
Download
Mailing Lists
Language Bindings
Themes
Bug Tracker

Documentation
FAQ
Tutorial
API Reference
Published Books

Projects
Pango
Inti
GNOME
GTK+ for Win32
GtkFB (Framebuffer)
GTK+ on DirectFB
GTK+ for BeOS

Applications
GIMP
Abiword
Dia
Glade
GnuCash
Gnumeric

GNOME Software Map

22.7. Utility and Error Functions

gchar *g_strdup( const gchar *str );

Replacement strdup function. Copies the original strings contents to newly allocated memory, and returns a pointer to it.

gchar *g_strerror( gint errnum );

I recommend using this for all error messages. It's much nicer, and more portable than perror() or others. The output is usually of the form:

program name:function that failed:file or further description:strerror

Here's an example of one such call used in our hello_world program:

g_print("hello_world:open:%s:%s\n", filename, g_strerror(errno));
void g_error( gchar *format, ... );

Prints an error message. The format is just like printf, but it prepends "** ERROR **: " to your message, and exits the program. Use only for fatal errors.

void g_warning( gchar *format, ... );

Same as above, but prepends "** WARNING **: ", and does not exit the program.

void g_message( gchar *format, ... );

Prints "message: " prepended to the string you pass in.

void g_print( gchar *format, ... );

Replacement for printf().

And our last function:

gchar *g_strsignal( gint signum );

Prints out the name of the Unix system signal given the signal number. Useful in generic signal handling functions.

All of the above are more or less just stolen from glib.h. If anyone cares to document any function, just send me an email!