Possible Duplicate:
Why does glib redefine types?
In the GTK+ 2.0 tutorial, I can read here the following statement about data types:
There are a few things you probably noticed in the previous examples that need explaining. The gint, gchar, etc. that you see are typedefs to int and char, respectively, that are part of the GLib system. This is done to get around that nasty dependency on the size of simple data types when doing calculations.
I don't understand the last part of this explanation. Why is it better to use Glib data types?
As the tutorial mentions, it's to ensure portability. When building code that uses glib on a new system you'd only have to modify the header file with the typedefs, not the code that uses those types.
The C99 standard added fixed-width types (int8_t, uint32_t, etc) which would make the glib types obsolete, but glib predates the C99 standard which probably is the reason why it has its own set of types.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With