tags:

views:

133

answers:

1

What is the reasoning behind types to be redefined in glib? Why do they turn char into gchar, int into gint etc. ?

+7  A: 

Check out Basic Types in the GLib documentation. Essentially, it's to guarantee that certain types will exist with certain semantics, regardless of which C compiler or platform you're using. The types that C guarantees anyway are typedefed just to make all of the type names look uniform.

jleedev
So the reason to turn char into gchar is to make it look prettier?
Lucas
In a way, but mainly because int for example may not be the same on all systems, gint8 will always be 8 bits however.
Dave
I guess. Some of the gtypes (arguably) give extra semantics over a simple type, but I think the rest are just for consistency and portability. Also remember that GLib dates from 1999, predating the widespread availability of types like `uint64_t`, which is why they roll their own.
jleedev