<refentry id="glib-Basic-Types">
<refmeta>
<refentrytitle>Basic Types</refentrytitle>
<manvolnum>3</manvolnum>
<refmiscinfo>GLIB Library</refmiscinfo>
</refmeta>

<refnamediv>
<refname>Basic Types</refname><refpurpose>standard GLib types, defined for ease-of-use and portability.</refpurpose>
</refnamediv>

<refsynopsisdiv><title>Synopsis</title>
<synopsis>

#include &lt;glib.h&gt;


typedef     <link linkend="gboolean">gboolean</link>;
typedef     <link linkend="gpointer">gpointer</link>;
typedef     <link linkend="gconstpointer">gconstpointer</link>;
typedef     <link linkend="gchar">gchar</link>;
typedef     <link linkend="guchar">guchar</link>;

typedef     <link linkend="gint">gint</link>;
typedef     <link linkend="guint">guint</link>;
typedef     <link linkend="gshort">gshort</link>;
typedef     <link linkend="gushort">gushort</link>;
typedef     <link linkend="glong">glong</link>;
typedef     <link linkend="gulong">gulong</link>;

typedef     <link linkend="gint8">gint8</link>;
typedef     <link linkend="guint8">guint8</link>;
typedef     <link linkend="gint16">gint16</link>;
typedef     <link linkend="guint16">guint16</link>;
typedef     <link linkend="gint32">gint32</link>;
typedef     <link linkend="guint32">guint32</link>;

#define     <link linkend="G-HAVE-GINT64-CAPS">G_HAVE_GINT64</link>
typedef     <link linkend="gint64">gint64</link>;
typedef     <link linkend="guint64">guint64</link>;
#define     <link linkend="G-GINT64-CONSTANT-CAPS">G_GINT64_CONSTANT</link>               (val)

typedef     <link linkend="gfloat">gfloat</link>;
typedef     <link linkend="gdouble">gdouble</link>;

typedef     <link linkend="gsize">gsize</link>;
typedef     <link linkend="gssize">gssize</link>;

</synopsis>
</refsynopsisdiv>





<refsect1>
<title>Description</title>
<para>
GLib defines a number of commonly used types, which can be divided into
4 groups:

<itemizedlist>
<listitem><para>
New types which are not part of standard C - <link linkend="gboolean">gboolean</link>, <link linkend="gsize">gsize</link>, <link linkend="gssize">gssize</link>.
</para></listitem>

<listitem><para>
Integer types which are guaranteed to be the same size across all platforms -
<link linkend="gint8">gint8</link>, <link linkend="guint8">guint8</link>, <link linkend="gint16">gint16</link>, <link linkend="guint16">guint16</link>, <link linkend="gint32">gint32</link>, <link linkend="guint32">guint32</link>, <link linkend="gint64">gint64</link>, <link linkend="guint64">guint64</link>.
</para></listitem>

<listitem><para>
Types which are easier to use than their standard C counterparts -
<link linkend="gpointer">gpointer</link>, <link linkend="gconstpointer">gconstpointer</link>, <link linkend="guchar">guchar</link>, <link linkend="guint">guint</link>, <link linkend="gushort">gushort</link>, <link linkend="gulong">gulong</link>.
</para></listitem>

<listitem><para>
Types which correspond exactly to standard C types, but are included
for completeness - <link linkend="gchar">gchar</link>, <link linkend="gint">gint</link>, <link linkend="gshort">gshort</link>, <link linkend="glong">glong</link>, <link linkend="gfloat">gfloat</link>, <link linkend="gdouble">gdouble</link>.
</para></listitem>
</itemizedlist>

</para>
</refsect1>

<refsect1>
<title>Details</title>
<refsect2>
<title><anchor id="gboolean">gboolean</title>
<programlisting>typedef gint   gboolean;
</programlisting>
<para>
A standard <type>boolean</type> type.
Variables of this type should only contain the value <link linkend="TRUE-CAPS">TRUE</link> or <link linkend="FALSE-CAPS">FALSE</link>.
</para></refsect2>
<refsect2>
<title><anchor id="gpointer">gpointer</title>
<programlisting>typedef void* gpointer;
</programlisting>
<para>
An untyped pointer.
<link linkend="gpointer">gpointer</link> looks better and is easier to use than <type>void*</type>.
</para></refsect2>
<refsect2>
<title><anchor id="gconstpointer">gconstpointer</title>
<programlisting>typedef const void *gconstpointer;
</programlisting>
<para>
An untyped pointer to constant data.
The data pointed to should not be changed.
</para>
<para>
This is typically used in function prototypes to indicate that the
data pointed to will not be altered by the function.
</para></refsect2>
<refsect2>
<title><anchor id="gchar">gchar</title>
<programlisting>typedef char   gchar;
</programlisting>
<para>
Corresponds to the standard C <type>char</type> type.
</para></refsect2>
<refsect2>
<title><anchor id="guchar">guchar</title>
<programlisting>typedef unsigned char   guchar;
</programlisting>
<para>
Corresponds to the standard C <type>unsigned char</type> type.
</para></refsect2>
<refsect2>
<title><anchor id="gint">gint</title>
<programlisting>typedef int    gint;
</programlisting>
<para>
Corresponds to the standard C <type>int</type> type.
Values of this type can range from <link linkend="G-MININT-CAPS">G_MININT</link> to <link linkend="G-MAXINT-CAPS">G_MAXINT</link>.
</para></refsect2>
<refsect2>
<title><anchor id="guint">guint</title>
<programlisting>typedef unsigned int    guint;
</programlisting>
<para>
Corresponds to the standard C <type>unsigned int</type> type.
Values of this type can range from 0 to <link linkend="G-MAXUINT-CAPS">G_MAXUINT</link>.
</para></refsect2>
<refsect2>
<title><anchor id="gshort">gshort</title>
<programlisting>typedef short  gshort;
</programlisting>
<para>
Corresponds to the standard C <type>short</type> type.
Values of this type can range from <link linkend="G-MINSHORT-CAPS">G_MINSHORT</link> to <link linkend="G-MAXSHORT-CAPS">G_MAXSHORT</link>.
</para></refsect2>
<refsect2>
<title><anchor id="gushort">gushort</title>
<programlisting>typedef unsigned short  gushort;
</programlisting>
<para>
Corresponds to the standard C <type>unsigned short</type> type.
Values of this type can range from 0 to <link linkend="G-MAXUSHORT-CAPS">G_MAXUSHORT</link>.
</para></refsect2>
<refsect2>
<title><anchor id="glong">glong</title>
<programlisting>typedef long   glong;
</programlisting>
<para>
Corresponds to the standard C <type>long</type> type.
Values of this type can range from <link linkend="G-MINLONG-CAPS">G_MINLONG</link> to <link linkend="G-MAXLONG-CAPS">G_MAXLONG</link>.
</para></refsect2>
<refsect2>
<title><anchor id="gulong">gulong</title>
<programlisting>typedef unsigned long   gulong;
</programlisting>
<para>
Corresponds to the standard C <type>unsigned long</type> type.
Values of this type can range from 0 to <link linkend="G-MAXULONG-CAPS">G_MAXULONG</link>.
</para></refsect2>
<refsect2>
<title><anchor id="gint8">gint8</title>
<programlisting>typedef signed char gint8;
</programlisting>
<para>
A signed integer guaranteed to be 8 bits on all platforms.
Values of this type can range from -128 to 127.
</para></refsect2>
<refsect2>
<title><anchor id="guint8">guint8</title>
<programlisting>typedef unsigned char guint8;
</programlisting>
<para>
An unsigned integer guaranteed to be 8 bits on all platforms.
Values of this type can range from 0 to 255.
</para></refsect2>
<refsect2>
<title><anchor id="gint16">gint16</title>
<programlisting>typedef signed short gint16;
</programlisting>
<para>
A signed integer guaranteed to be 16 bits on all platforms.
Values of this type can range from -32,768 to 32,767.
</para></refsect2>
<refsect2>
<title><anchor id="guint16">guint16</title>
<programlisting>typedef unsigned short guint16;
</programlisting>
<para>
An unsigned integer guaranteed to be 16 bits on all platforms.
Values of this type can range from 0 to 65,535.
</para></refsect2>
<refsect2>
<title><anchor id="gint32">gint32</title>
<programlisting>typedef signed int gint32;
</programlisting>
<para>
A signed integer guaranteed to be 32 bits on all platforms.
Values of this type can range from -2,147,483,648 to 2,147,483,647.
</para></refsect2>
<refsect2>
<title><anchor id="guint32">guint32</title>
<programlisting>typedef unsigned int guint32;
</programlisting>
<para>
An unsigned integer guaranteed to be 32 bits on all platforms.
Values of this type can range from 0 to 4,294,967,295.
</para></refsect2>
<refsect2>
<title><anchor id="G-HAVE-GINT64-CAPS">G_HAVE_GINT64</title>
<programlisting>#define G_HAVE_GINT64 1          /* deprecated, always true */
</programlisting>
<para>
This macro is defined if 64-bit signed and unsigned integers are available
on the platform.
</para></refsect2>
<refsect2>
<title><anchor id="gint64">gint64</title>
<programlisting>G_GNUC_EXTENSION typedef signed long long gint64;
</programlisting>
<para>
A signed integer guaranteed to be 64 bits on all platforms on which it is
available (see <link linkend="G-HAVE-GINT64-CAPS">G_HAVE_GINT64</link>).
Values of this type can range from -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807.
</para></refsect2>
<refsect2>
<title><anchor id="guint64">guint64</title>
<programlisting>G_GNUC_EXTENSION typedef unsigned long long guint64;
</programlisting>
<para>
An unsigned integer guaranteed to be 64 bits on all platforms on which it is
available (see <link linkend="G-HAVE-GINT64-CAPS">G_HAVE_GINT64</link>).
Values of this type can range from 0 to 18,446,744,073,709,551,615.
</para></refsect2>
<refsect2>
<title><anchor id="G-GINT64-CONSTANT-CAPS">G_GINT64_CONSTANT()</title>
<programlisting>#define G_GINT64_CONSTANT(val)	(G_GNUC_EXTENSION (val##LL))
</programlisting>
<para>
This macro is used to insert 64-bit integer literals into the source code.
</para><informaltable pgwide="1" frame="none" role="params">
<tgroup cols="2">
<colspec colwidth="2*">
<colspec colwidth="8*">
<tbody>
<row><entry align="right"><parameter>val</parameter>&nbsp;:</entry>
<entry>a literal integer value, e.g. 0x1d636b02300a7aa7U.


</entry></row>
</tbody></tgroup></informaltable></refsect2>
<refsect2>
<title><anchor id="gfloat">gfloat</title>
<programlisting>typedef float   gfloat;
</programlisting>
<para>
Corresponds to the standard C <type>float</type> type.
Values of this type can range from <link linkend="G-MINFLOAT-CAPS">G_MINFLOAT</link> to <link linkend="G-MAXFLOAT-CAPS">G_MAXFLOAT</link>.
</para></refsect2>
<refsect2>
<title><anchor id="gdouble">gdouble</title>
<programlisting>typedef double  gdouble;
</programlisting>
<para>
Corresponds to the standard C <type>double</type> type.
Values of this type can range from <link linkend="G-MINDOUBLE-CAPS">G_MINDOUBLE</link> to <link linkend="G-MAXDOUBLE-CAPS">G_MAXDOUBLE</link>.
</para></refsect2>
<refsect2>
<title><anchor id="gsize">gsize</title>
<programlisting>typedef unsigned int gsize;
</programlisting>
<para>
An unsigned 32-bit integer intended to represent sizes of data structures.
</para></refsect2>
<refsect2>
<title><anchor id="gssize">gssize</title>
<programlisting>typedef signed int gssize;
</programlisting>
<para>
A signed 32-bit integer intended to represent sizes of data structures.
</para></refsect2>

</refsect1>




</refentry>
