Basic Types

Basic Types — standard GLib types, defined for ease-of-use and portability

Synopsis


#include <glib.h>

typedef             gboolean;
typedef             gpointer;
typedef             gconstpointer;
typedef             gchar;
typedef             guchar;

typedef             gint;
typedef             guint;
typedef             gshort;
typedef             gushort;
typedef             glong;
typedef             gulong;


GLIB_VAR            guint64                             ();

typedef             gfloat;
typedef             gdouble;

Description

GLib defines a number of commonly used types, which can be divided into 4 groups:

  • New types which are not part of standard C - gboolean, gsize, gssize.

  • Integer types which are guaranteed to be the same size across all platforms - gint8, guint8, gint16, guint16, gint32, guint32, gint64, guint64.

  • Types which are easier to use than their standard C counterparts - gpointer, gconstpointer, guchar, guint, gushort, gulong.

  • Types which correspond exactly to standard C types, but are included for completeness - gchar, gint, gshort, glong, gfloat, gdouble.

Details

gboolean

typedef gint   gboolean;

A standard boolean type. Variables of this type should only contain the value TRUE or FALSE.


gpointer

typedef void* gpointer;

An untyped pointer. gpointer looks better and is easier to use than void*.


gconstpointer

typedef const void *gconstpointer;

An untyped pointer to constant data. The data pointed to should not be changed.

This is typically used in function prototypes to indicate that the data pointed to will not be altered by the function.


gchar

typedef char   gchar;

Corresponds to the standard C char type.


guchar

typedef unsigned char   guchar;

Corresponds to the standard C unsigned char type.


gint

typedef int    gint;

Corresponds to the standard C int type. Values of this type can range from G_MININT to G_MAXINT.


guint

typedef unsigned int    guint;

Corresponds to the standard C unsigned int type. Values of this type can range from 0 to G_MAXUINT.


gshort

typedef short  gshort;

Corresponds to the standard C short type. Values of this type can range from G_MINSHORT to G_MAXSHORT.


gushort

typedef unsigned short  gushort;

Corresponds to the standard C unsigned short type. Values of this type can range from 0 to G_MAXUSHORT.


glong

typedef long   glong;

Corresponds to the standard C long type. Values of this type can range from G_MINLONG to G_MAXLONG.


gulong

typedef unsigned long   gulong;

Corresponds to the standard C unsigned long type. Values of this type can range from 0 to G_MAXULONG.


guint64 ()

GLIB_VAR            guint64                             ();

An unsigned integer guaranteed to be 64 bits on all platforms. Values of this type can range from 0 to 18,446,744,073,709,551,615.

Returns :

gfloat

typedef float   gfloat;

Corresponds to the standard C float type. Values of this type can range from -G_MAXFLOAT to G_MAXFLOAT.


gdouble

typedef double  gdouble;

Corresponds to the standard C double type. Values of this type can range from -G_MAXDOUBLE to G_MAXDOUBLE.