types.xml   [plain text]


<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"><type>gboolean</type></link>, <link linkend="gsize"><type>gsize</type></link>, <link linkend="gssize"><type>gssize</type></link>.
</para></listitem>

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

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

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

</para>
</refsect1>

<refsect1>
<title>Details</title>
<refsect2>
<title><anchor id="gboolean"/>gboolean</title>
<indexterm><primary>gboolean</primary></indexterm><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"><type>TRUE</type></link> or <link linkend="FALSE-CAPS"><type>FALSE</type></link>.
</para></refsect2>
<refsect2>
<title><anchor id="gpointer"/>gpointer</title>
<indexterm><primary>gpointer</primary></indexterm><programlisting>typedef void* gpointer;
</programlisting>
<para>
An untyped pointer.
<link linkend="gpointer"><type>gpointer</type></link> looks better and is easier to use than <type>void*</type>.
</para></refsect2>
<refsect2>
<title><anchor id="gconstpointer"/>gconstpointer</title>
<indexterm><primary>gconstpointer</primary></indexterm><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>
<indexterm><primary>gchar</primary></indexterm><programlisting>typedef char   gchar;
</programlisting>
<para>
Corresponds to the standard C <type>char</type> type.
</para></refsect2>
<refsect2>
<title><anchor id="guchar"/>guchar</title>
<indexterm><primary>guchar</primary></indexterm><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>
<indexterm><primary>gint</primary></indexterm><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"><type>G_MININT</type></link> to <link linkend="G-MAXINT-CAPS"><type>G_MAXINT</type></link>.
</para></refsect2>
<refsect2>
<title><anchor id="guint"/>guint</title>
<indexterm><primary>guint</primary></indexterm><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"><type>G_MAXUINT</type></link>.
</para></refsect2>
<refsect2>
<title><anchor id="gshort"/>gshort</title>
<indexterm><primary>gshort</primary></indexterm><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"><type>G_MINSHORT</type></link> to <link linkend="G-MAXSHORT-CAPS"><type>G_MAXSHORT</type></link>.
</para></refsect2>
<refsect2>
<title><anchor id="gushort"/>gushort</title>
<indexterm><primary>gushort</primary></indexterm><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"><type>G_MAXUSHORT</type></link>.
</para></refsect2>
<refsect2>
<title><anchor id="glong"/>glong</title>
<indexterm><primary>glong</primary></indexterm><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"><type>G_MINLONG</type></link> to <link linkend="G-MAXLONG-CAPS"><type>G_MAXLONG</type></link>.
</para></refsect2>
<refsect2>
<title><anchor id="gulong"/>gulong</title>
<indexterm><primary>gulong</primary></indexterm><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"><type>G_MAXULONG</type></link>.
</para></refsect2>
<refsect2>
<title><anchor id="gint8"/>gint8</title>
<indexterm><primary>gint8</primary></indexterm><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>
<indexterm><primary>guint8</primary></indexterm><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>
<indexterm><primary>gint16</primary></indexterm><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>
<indexterm><primary>guint16</primary></indexterm><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>
<indexterm><primary>gint32</primary></indexterm><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>
<indexterm><primary>guint32</primary></indexterm><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>
<indexterm><primary>G_HAVE_GINT64</primary></indexterm><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>
<indexterm><primary>gint64</primary></indexterm><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"><type>G_HAVE_GINT64</type></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>
<indexterm><primary>guint64</primary></indexterm><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"><type>G_HAVE_GINT64</type></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>
<indexterm><primary>G_GINT64_CONSTANT</primary></indexterm><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><variablelist role="params">
<varlistentry><term><parameter>val</parameter>&nbsp;:</term>
<listitem><simpara>a literal integer value, e.g. 0x1d636b02300a7aa7U.


</simpara></listitem></varlistentry>
</variablelist></refsect2>
<refsect2>
<title><anchor id="gfloat"/>gfloat</title>
<indexterm><primary>gfloat</primary></indexterm><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-MAXFLOAT-CAPS"><type>G_MAXFLOAT</type></link> to <link linkend="G-MAXFLOAT-CAPS"><type>G_MAXFLOAT</type></link>.
</para></refsect2>
<refsect2>
<title><anchor id="gdouble"/>gdouble</title>
<indexterm><primary>gdouble</primary></indexterm><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-MAXDOUBLE-CAPS"><type>G_MAXDOUBLE</type></link> to <link linkend="G-MAXDOUBLE-CAPS"><type>G_MAXDOUBLE</type></link>.
</para></refsect2>
<refsect2>
<title><anchor id="gsize"/>gsize</title>
<indexterm><primary>gsize</primary></indexterm><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>
<indexterm><primary>gssize</primary></indexterm><programlisting>typedef signed int gssize;
</programlisting>
<para>
A signed 32-bit integer intended to represent sizes of data structures.
</para></refsect2>

</refsect1>




</refentry>