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 typedef
ed just to make all of the type names look uniform.
jleedev
2009-11-30 12:38:06
So the reason to turn char into gchar is to make it look prettier?
Lucas
2009-11-30 12:41:39
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
2009-11-30 13:08:36
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
2009-11-30 13:08:40