glib-Basic-Types.html   [plain text]


<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Basic Types</title><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="GLib Reference Manual"><link rel="up" href="glib-fundamentals.html" title="GLib Fundamentals"><link rel="previous" href="glib-fundamentals.html" title="GLib Fundamentals"><link rel="next" href="glib-Limits-of-Basic-Types.html" title="Limits of Basic Types"><link rel="chapter" href="glib.html" title="GLib Overview"><link rel="refentry" href="glib-building.html" title="Compiling the GLib package"><link rel="refentry" href="glib-cross-compiling.html" title="Cross-compiling the GLib package"><link rel="refentry" href="glib-compiling.html" title="Compiling GLib Applications"><link rel="refentry" href="glib-running.html" title="Running GLib Applications"><link rel="refentry" href="glib-changes.html" title="Changes to GLib"><link rel="refentry" href="glib-resources.html" title="Mailing lists and bug reports"><link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals"><link rel="refentry" href="glib-Basic-Types.html" title="Basic Types"><link rel="refentry" href="glib-Limits-of-Basic-Types.html" title="Limits of Basic Types"><link rel="refentry" href="glib-Standard-Macros.html" title="Standard Macros"><link rel="refentry" href="glib-Type-Conversion-Macros.html" title="Type Conversion Macros"><link rel="refentry" href="glib-Byte-Order-Macros.html" title="Byte Order Macros"><link rel="refentry" href="glib-Numerical-Definitions.html" title="Numerical Definitions"><link rel="refentry" href="glib-Miscellaneous-Macros.html" title="Miscellaneous Macros"><link rel="refentry" href="glib-Atomic-Operations.html" title="Atomic Operations"><link rel="chapter" href="glib-core.html" title="GLib Core Application Support"><link rel="refentry" href="glib-The-Main-Event-Loop.html" title="The Main Event Loop"><link rel="refentry" href="glib-Threads.html" title="
Threads"><link rel="refentry" href="glib-Thread-Pools.html" title="Thread Pools"><link rel="refentry" href="glib-Asynchronous-Queues.html" title="Asynchronous Queues"><link rel="refentry" href="glib-Dynamic-Loading-of-Modules.html" title="Dynamic Loading of Modules"><link rel="refentry" href="glib-Memory-Allocation.html" title="Memory Allocation"><link rel="refentry" href="glib-IO-Channels.html" title="IO Channels"><link rel="refentry" href="glib-Error-Reporting.html" title="Error Reporting"><link rel="refentry" href="glib-Warnings-and-Assertions.html" title="Message Output and Debugging Functions"><link rel="refentry" href="glib-Message-Logging.html" title="Message Logging"><link rel="chapter" href="glib-utilities.html" title="GLib Utilities"><link rel="refentry" href="glib-String-Utility-Functions.html" title="String Utility Functions"><link rel="refentry" href="glib-Character-Set-Conversion.html" title="Character Set Conversion"><link rel="refentry" href="glib-Unicode-Manipulation.html" title="Unicode Manipulation"><link rel="refentry" href="glib-I18N.html" title="Internationalization"><link rel="refentry" href="glib-Date-and-Time-Functions.html" title="Date and Time Functions"><link rel="refentry" href="glib-Random-Numbers.html" title="Random Numbers"><link rel="refentry" href="glib-Hook-Functions.html" title="Hook Functions"><link rel="refentry" href="glib-Miscellaneous-Utility-Functions.html" title="Miscellaneous Utility Functions"><link rel="refentry" href="glib-Lexical-Scanner.html" title="Lexical Scanner"><link rel="refentry" href="glib-Automatic-String-Completion.html" title="Automatic String Completion"><link rel="refentry" href="glib-Timers.html" title="Timers"><link rel="refentry" href="glib-Spawning-Processes.html" title="Spawning Processes"><link rel="refentry" href="glib-File-Utilities.html" title="File Utilities"><link rel="refentry" href="glib-Shell-related-Utilities.html" title="Shell-related Utilities"><link rel="refentry" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching"><link rel="refentry" href="glib-Simple-XML-Subset-Parser.html" title="Simple XML Subset Parser"><link rel="refentry" href="glib-Windows-Compatability-Functions.html" title="Windows Compatibility Functions"><link rel="chapter" href="glib-data-types.html" title="GLib Data Types"><link rel="refentry" href="glib-Memory-Chunks.html" title="Memory Chunks"><link rel="refentry" href="glib-Doubly-Linked-Lists.html" title="Doubly-Linked Lists"><link rel="refentry" href="glib-Singly-Linked-Lists.html" title="Singly-Linked Lists"><link rel="refentry" href="glib-Double-ended-Queues.html" title="Double-ended Queues"><link rel="refentry" href="glib-Trash-Stacks.html" title="Trash Stacks"><link rel="refentry" href="glib-Hash-Tables.html" title="Hash Tables"><link rel="refentry" href="glib-Strings.html" title="Strings"><link rel="refentry" href="glib-String-Chunks.html" title="String Chunks"><link rel="refentry" href="glib-Arrays.html" title="Arrays"><link rel="refentry" href="glib-Pointer-Arrays.html" title="Pointer Arrays"><link rel="refentry" href="glib-Byte-Arrays.html" title="Byte Arrays"><link rel="refentry" href="glib-Balanced-Binary-Trees.html" title="Balanced Binary Trees"><link rel="refentry" href="glib-N-ary-Trees.html" title="N-ary Trees"><link rel="refentry" href="glib-Quarks.html" title="Quarks"><link rel="refentry" href="glib-Keyed-Data-Lists.html" title="Keyed Data Lists"><link rel="refentry" href="glib-Datasets.html" title="Datasets"><link rel="refentry" href="glib-Relations-and-Tuples.html" title="Relations and Tuples"><link rel="refentry" href="glib-Caches.html" title="Caches"><link rel="refentry" href="glib-Memory-Allocators.html" title="Memory Allocators"><link rel="chapter" href="tools.html" title="GLib Tools"><link rel="refentry" href="glib-gettextize.html" title="glib-gettextize"><link rel="index" href="ix01.html" title="Index"><link rel="section" href="glib-Basic-Types.html#id2973598" title="Description"><link rel="section" href="glib-Basic-Types.html#id2973814" title="Details"><meta name="generator" content="GTK-Doc V1.2 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="glib-fundamentals.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="glib-fundamentals.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GLib Reference Manual</th><td><a accesskey="n" href="glib-Limits-of-Basic-Types.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr></table><div class="refentry" lang="en"><a name="glib-Basic-Types"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2><span class="refentrytitle">Basic Types</span></h2><p>Basic Types &#8212; standard GLib types, defined for ease-of-use and portability.</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">

#include &lt;glib.h&gt;


typedef     <a href="glib-Basic-Types.html#gboolean">gboolean</a>;
typedef     <a href="glib-Basic-Types.html#gpointer">gpointer</a>;
typedef     <a href="glib-Basic-Types.html#gconstpointer">gconstpointer</a>;
typedef     <a href="glib-Basic-Types.html#gchar">gchar</a>;
typedef     <a href="glib-Basic-Types.html#guchar">guchar</a>;

typedef     <a href="glib-Basic-Types.html#gint">gint</a>;
typedef     <a href="glib-Basic-Types.html#guint">guint</a>;
typedef     <a href="glib-Basic-Types.html#gshort">gshort</a>;
typedef     <a href="glib-Basic-Types.html#gushort">gushort</a>;
typedef     <a href="glib-Basic-Types.html#glong">glong</a>;
typedef     <a href="glib-Basic-Types.html#gulong">gulong</a>;

typedef     <a href="glib-Basic-Types.html#gint8">gint8</a>;
typedef     <a href="glib-Basic-Types.html#guint8">guint8</a>;
typedef     <a href="glib-Basic-Types.html#gint16">gint16</a>;
typedef     <a href="glib-Basic-Types.html#guint16">guint16</a>;
typedef     <a href="glib-Basic-Types.html#gint32">gint32</a>;
typedef     <a href="glib-Basic-Types.html#guint32">guint32</a>;

#define     <a href="glib-Basic-Types.html#G-HAVE-GINT64-CAPS">G_HAVE_GINT64</a>
typedef     <a href="glib-Basic-Types.html#gint64">gint64</a>;
typedef     <a href="glib-Basic-Types.html#guint64">guint64</a>;
#define     <a href="glib-Basic-Types.html#G-GINT64-CONSTANT-CAPS">G_GINT64_CONSTANT</a>               (val)

typedef     <a href="glib-Basic-Types.html#gfloat">gfloat</a>;
typedef     <a href="glib-Basic-Types.html#gdouble">gdouble</a>;

typedef     <a href="glib-Basic-Types.html#gsize">gsize</a>;
typedef     <a href="glib-Basic-Types.html#gssize">gssize</a>;

</pre></div><div class="refsect1" lang="en"><a name="id2973598"></a><h2>Description</h2><p>
GLib defines a number of commonly used types, which can be divided into
4 groups:

</p><div class="itemizedlist"><ul type="disc"><li><p>
New types which are not part of standard C - <a href="glib-Basic-Types.html#gboolean"><span class="type">gboolean</span></a>, <a href="glib-Basic-Types.html#gsize"><span class="type">gsize</span></a>, <a href="glib-Basic-Types.html#gssize"><span class="type">gssize</span></a>.
</p></li><li><p>
Integer types which are guaranteed to be the same size across all platforms -
<a href="glib-Basic-Types.html#gint8"><span class="type">gint8</span></a>, <a href="glib-Basic-Types.html#guint8"><span class="type">guint8</span></a>, <a href="glib-Basic-Types.html#gint16"><span class="type">gint16</span></a>, <a href="glib-Basic-Types.html#guint16"><span class="type">guint16</span></a>, <a href="glib-Basic-Types.html#gint32"><span class="type">gint32</span></a>, <a href="glib-Basic-Types.html#guint32"><span class="type">guint32</span></a>, <a href="glib-Basic-Types.html#gint64"><span class="type">gint64</span></a>, <a href="glib-Basic-Types.html#guint64"><span class="type">guint64</span></a>.
</p></li><li><p>
Types which are easier to use than their standard C counterparts -
<a href="glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a>, <a href="glib-Basic-Types.html#gconstpointer"><span class="type">gconstpointer</span></a>, <a href="glib-Basic-Types.html#guchar"><span class="type">guchar</span></a>, <a href="glib-Basic-Types.html#guint"><span class="type">guint</span></a>, <a href="glib-Basic-Types.html#gushort"><span class="type">gushort</span></a>, <a href="glib-Basic-Types.html#gulong"><span class="type">gulong</span></a>.
</p></li><li><p>
Types which correspond exactly to standard C types, but are included
for completeness - <a href="glib-Basic-Types.html#gchar"><span class="type">gchar</span></a>, <a href="glib-Basic-Types.html#gint"><span class="type">gint</span></a>, <a href="glib-Basic-Types.html#gshort"><span class="type">gshort</span></a>, <a href="glib-Basic-Types.html#glong"><span class="type">glong</span></a>, <a href="glib-Basic-Types.html#gfloat"><span class="type">gfloat</span></a>, <a href="glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a>.
</p></li></ul></div><p>

</p></div><div class="refsect1" lang="en"><a name="id2973814"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id2973819"></a><h3><a name="gboolean"></a>gboolean</h3><a class="indexterm" name="id2973829"></a><pre class="programlisting">typedef gint   gboolean;
</pre><p>
A standard <span class="type">boolean</span> type.
Variables of this type should only contain the value <a href="glib-Standard-Macros.html#TRUE-CAPS"><span class="type">TRUE</span></a> or <a href="glib-Standard-Macros.html#FALSE-CAPS"><span class="type">FALSE</span></a>.
</p></div><hr><div class="refsect2" lang="en"><a name="id2973866"></a><h3><a name="gpointer"></a>gpointer</h3><a class="indexterm" name="id2973876"></a><pre class="programlisting">typedef void* gpointer;
</pre><p>
An untyped pointer.
<a href="glib-Basic-Types.html#gpointer"><span class="type">gpointer</span></a> looks better and is easier to use than <span class="type">void*</span>.
</p></div><hr><div class="refsect2" lang="en"><a name="id2973904"></a><h3><a name="gconstpointer"></a>gconstpointer</h3><a class="indexterm" name="id2973914"></a><pre class="programlisting">typedef const void *gconstpointer;
</pre><p>
An untyped pointer to constant data.
The data pointed to should not be changed.
</p><p>
This is typically used in function prototypes to indicate that the
data pointed to will not be altered by the function.
</p></div><hr><div class="refsect2" lang="en"><a name="id2973937"></a><h3><a name="gchar"></a>gchar</h3><a class="indexterm" name="id2973947"></a><pre class="programlisting">typedef char   gchar;
</pre><p>
Corresponds to the standard C <span class="type">char</span> type.
</p></div><hr><div class="refsect2" lang="en"><a name="id2973966"></a><h3><a name="guchar"></a>guchar</h3><a class="indexterm" name="id2973976"></a><pre class="programlisting">typedef unsigned char   guchar;
</pre><p>
Corresponds to the standard C <span class="type">unsigned char</span> type.
</p></div><hr><div class="refsect2" lang="en"><a name="id2973996"></a><h3><a name="gint"></a>gint</h3><a class="indexterm" name="id2974006"></a><pre class="programlisting">typedef int    gint;
</pre><p>
Corresponds to the standard C <span class="type">int</span> type.
Values of this type can range from <a href="glib-Limits-of-Basic-Types.html#G-MININT-CAPS"><span class="type">G_MININT</span></a> to <a href="glib-Limits-of-Basic-Types.html#G-MAXINT-CAPS"><span class="type">G_MAXINT</span></a>.
</p></div><hr><div class="refsect2" lang="en"><a name="id2974044"></a><h3><a name="guint"></a>guint</h3><a class="indexterm" name="id2974054"></a><pre class="programlisting">typedef unsigned int    guint;
</pre><p>
Corresponds to the standard C <span class="type">unsigned int</span> type.
Values of this type can range from 0 to <a href="glib-Limits-of-Basic-Types.html#G-MAXUINT-CAPS"><span class="type">G_MAXUINT</span></a>.
</p></div><hr><div class="refsect2" lang="en"><a name="id2974083"></a><h3><a name="gshort"></a>gshort</h3><a class="indexterm" name="id2974093"></a><pre class="programlisting">typedef short  gshort;
</pre><p>
Corresponds to the standard C <span class="type">short</span> type.
Values of this type can range from <a href="glib-Limits-of-Basic-Types.html#G-MINSHORT-CAPS"><span class="type">G_MINSHORT</span></a> to <a href="glib-Limits-of-Basic-Types.html#G-MAXSHORT-CAPS"><span class="type">G_MAXSHORT</span></a>.
</p></div><hr><div class="refsect2" lang="en"><a name="id2974132"></a><h3><a name="gushort"></a>gushort</h3><a class="indexterm" name="id2974142"></a><pre class="programlisting">typedef unsigned short  gushort;
</pre><p>
Corresponds to the standard C <span class="type">unsigned short</span> type.
Values of this type can range from 0 to <a href="glib-Limits-of-Basic-Types.html#G-MAXUSHORT-CAPS"><span class="type">G_MAXUSHORT</span></a>.
</p></div><hr><div class="refsect2" lang="en"><a name="id2974171"></a><h3><a name="glong"></a>glong</h3><a class="indexterm" name="id2974181"></a><pre class="programlisting">typedef long   glong;
</pre><p>
Corresponds to the standard C <span class="type">long</span> type.
Values of this type can range from <a href="glib-Limits-of-Basic-Types.html#G-MINLONG-CAPS"><span class="type">G_MINLONG</span></a> to <a href="glib-Limits-of-Basic-Types.html#G-MAXLONG-CAPS"><span class="type">G_MAXLONG</span></a>.
</p></div><hr><div class="refsect2" lang="en"><a name="id2974220"></a><h3><a name="gulong"></a>gulong</h3><a class="indexterm" name="id2974230"></a><pre class="programlisting">typedef unsigned long   gulong;
</pre><p>
Corresponds to the standard C <span class="type">unsigned long</span> type.
Values of this type can range from 0 to <a href="glib-Limits-of-Basic-Types.html#G-MAXULONG-CAPS"><span class="type">G_MAXULONG</span></a>.
</p></div><hr><div class="refsect2" lang="en"><a name="id2974259"></a><h3><a name="gint8"></a>gint8</h3><a class="indexterm" name="id2974269"></a><pre class="programlisting">typedef signed char gint8;
</pre><p>
A signed integer guaranteed to be 8 bits on all platforms.
Values of this type can range from -128 to 127.
</p></div><hr><div class="refsect2" lang="en"><a name="id2974286"></a><h3><a name="guint8"></a>guint8</h3><a class="indexterm" name="id2974297"></a><pre class="programlisting">typedef unsigned char guint8;
</pre><p>
An unsigned integer guaranteed to be 8 bits on all platforms.
Values of this type can range from 0 to 255.
</p></div><hr><div class="refsect2" lang="en"><a name="id2974314"></a><h3><a name="gint16"></a>gint16</h3><a class="indexterm" name="id2974324"></a><pre class="programlisting">typedef signed short gint16;
</pre><p>
A signed integer guaranteed to be 16 bits on all platforms.
Values of this type can range from -32,768 to 32,767.
</p></div><hr><div class="refsect2" lang="en"><a name="id2974341"></a><h3><a name="guint16"></a>guint16</h3><a class="indexterm" name="id2974351"></a><pre class="programlisting">typedef unsigned short guint16;
</pre><p>
An unsigned integer guaranteed to be 16 bits on all platforms.
Values of this type can range from 0 to 65,535.
</p></div><hr><div class="refsect2" lang="en"><a name="id2974368"></a><h3><a name="gint32"></a>gint32</h3><a class="indexterm" name="id2974379"></a><pre class="programlisting">typedef signed int gint32;
</pre><p>
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.
</p></div><hr><div class="refsect2" lang="en"><a name="id2974396"></a><h3><a name="guint32"></a>guint32</h3><a class="indexterm" name="id2974406"></a><pre class="programlisting">typedef unsigned int guint32;
</pre><p>
An unsigned integer guaranteed to be 32 bits on all platforms.
Values of this type can range from 0 to 4,294,967,295.
</p></div><hr><div class="refsect2" lang="en"><a name="id2974423"></a><h3><a name="G-HAVE-GINT64-CAPS"></a>G_HAVE_GINT64</h3><a class="indexterm" name="id2974434"></a><pre class="programlisting">#define G_HAVE_GINT64 1          /* deprecated, always true */
</pre><p>
This macro is defined if 64-bit signed and unsigned integers are available
on the platform.
</p></div><hr><div class="refsect2" lang="en"><a name="id2974452"></a><h3><a name="gint64"></a>gint64</h3><a class="indexterm" name="id2974462"></a><pre class="programlisting">G_GNUC_EXTENSION typedef signed long long gint64;
</pre><p>
A signed integer guaranteed to be 64 bits on all platforms on which it is
available (see <a href="glib-Basic-Types.html#G-HAVE-GINT64-CAPS"><span class="type">G_HAVE_GINT64</span></a>).
Values of this type can range from -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807.
</p></div><hr><div class="refsect2" lang="en"><a name="id2974488"></a><h3><a name="guint64"></a>guint64</h3><a class="indexterm" name="id2974498"></a><pre class="programlisting">G_GNUC_EXTENSION typedef unsigned long long guint64;
</pre><p>
An unsigned integer guaranteed to be 64 bits on all platforms on which it is
available (see <a href="glib-Basic-Types.html#G-HAVE-GINT64-CAPS"><span class="type">G_HAVE_GINT64</span></a>).
Values of this type can range from 0 to 18,446,744,073,709,551,615.
</p></div><hr><div class="refsect2" lang="en"><a name="id2974525"></a><h3><a name="G-GINT64-CONSTANT-CAPS"></a>G_GINT64_CONSTANT()</h3><a class="indexterm" name="id2974537"></a><pre class="programlisting">#define G_GINT64_CONSTANT(val)	(G_GNUC_EXTENSION (val##LL))
</pre><p>
This macro is used to insert 64-bit integer literals into the source code.
</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><i class="parameter"><tt>val</tt></i> :</span></td><td>a literal integer value, e.g. 0x1d636b02300a7aa7U.


</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2974574"></a><h3><a name="gfloat"></a>gfloat</h3><a class="indexterm" name="id2974583"></a><pre class="programlisting">typedef float   gfloat;
</pre><p>
Corresponds to the standard C <span class="type">float</span> type.
Values of this type can range from -<a href="glib-Limits-of-Basic-Types.html#G-MAXFLOAT-CAPS"><span class="type">G_MAXFLOAT</span></a> to <a href="glib-Limits-of-Basic-Types.html#G-MAXFLOAT-CAPS"><span class="type">G_MAXFLOAT</span></a>.
</p></div><hr><div class="refsect2" lang="en"><a name="id2974622"></a><h3><a name="gdouble"></a>gdouble</h3><a class="indexterm" name="id2974632"></a><pre class="programlisting">typedef double  gdouble;
</pre><p>
Corresponds to the standard C <span class="type">double</span> type.
Values of this type can range from -<a href="glib-Limits-of-Basic-Types.html#G-MAXDOUBLE-CAPS"><span class="type">G_MAXDOUBLE</span></a> to <a href="glib-Limits-of-Basic-Types.html#G-MAXDOUBLE-CAPS"><span class="type">G_MAXDOUBLE</span></a>.
</p></div><hr><div class="refsect2" lang="en"><a name="id2974669"></a><h3><a name="gsize"></a>gsize</h3><a class="indexterm" name="id2974679"></a><pre class="programlisting">typedef unsigned int gsize;
</pre><p>
An unsigned 32-bit integer intended to represent sizes of data structures.
</p></div><hr><div class="refsect2" lang="en"><a name="id2974695"></a><h3><a name="gssize"></a>gssize</h3><a class="indexterm" name="id2974705"></a><pre class="programlisting">typedef signed int gssize;
</pre><p>
A signed 32-bit integer intended to represent sizes of data structures.
</p></div></div></div><table class="navigation" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle"><td align="left"><a accesskey="p" href="glib-fundamentals.html"><b>&lt;&lt; GLib Fundamentals</b></a></td><td align="right"><a accesskey="n" href="glib-Limits-of-Basic-Types.html"><b>Limits of Basic Types &gt;&gt;</b></a></td></tr></table></body></html>