| <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> |
| <html> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
| <title>Miscellaneous Macros</title> |
| <meta name="generator" content="DocBook XSL Stylesheets V1.75.2"> |
| <link rel="home" href="index.html" title="GLib Reference Manual"> |
| <link rel="up" href="glib-fundamentals.html" title="GLib Fundamentals"> |
| <link rel="prev" href="glib-Numerical-Definitions.html" title="Numerical Definitions"> |
| <link rel="next" href="glib-Atomic-Operations.html" title="Atomic Operations"> |
| <meta name="generator" content="GTK-Doc V1.14 (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" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"> |
| <tr valign="middle"> |
| <td><a accesskey="p" href="glib-Numerical-Definitions.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-Atomic-Operations.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td> |
| </tr> |
| <tr><td colspan="5" class="shortcuts"> |
| <a href="#glib-Miscellaneous-Macros.synopsis" class="shortcut">Top</a> |
| | |
| <a href="#glib-Miscellaneous-Macros.description" class="shortcut">Description</a> |
| </td></tr> |
| </table> |
| <div class="refentry" title="Miscellaneous Macros"> |
| <a name="glib-Miscellaneous-Macros"></a><div class="titlepage"></div> |
| <div class="refnamediv"><table width="100%"><tr> |
| <td valign="top"> |
| <h2><span class="refentrytitle"><a name="glib-Miscellaneous-Macros.top_of_page"></a>Miscellaneous Macros</span></h2> |
| <p>Miscellaneous Macros — specialized macros which are not used often</p> |
| </td> |
| <td valign="top" align="right"></td> |
| </tr></table></div> |
| <div class="refsynopsisdiv" title="Synopsis"> |
| <a name="glib-Miscellaneous-Macros.synopsis"></a><h2>Synopsis</h2> |
| <pre class="synopsis"> |
| #include <glib.h> |
| |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-INLINE-FUNC:CAPS" title="G_INLINE_FUNC">G_INLINE_FUNC</a> |
| |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-STMT-START:CAPS" title="G_STMT_START">G_STMT_START</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-STMT-END:CAPS" title="G_STMT_END">G_STMT_END</a> |
| |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-BEGIN-DECLS:CAPS" title="G_BEGIN_DECLS">G_BEGIN_DECLS</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-END-DECLS:CAPS" title="G_END_DECLS">G_END_DECLS</a> |
| |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-N-ELEMENTS:CAPS" title="G_N_ELEMENTS()">G_N_ELEMENTS</a> (arr) |
| |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-VA-COPY:CAPS" title="G_VA_COPY()">G_VA_COPY</a> (ap1, |
| ap2) |
| |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-STRINGIFY:CAPS" title="G_STRINGIFY()">G_STRINGIFY</a> (macro_or_string) |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-PASTE:CAPS" title="G_PASTE()">G_PASTE</a> (identifier1, |
| identifier2) |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-PASTE-ARGS:CAPS" title="G_PASTE_ARGS()">G_PASTE_ARGS</a> (identifier1, |
| identifier2) |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-STATIC-ASSERT:CAPS" title="G_STATIC_ASSERT()">G_STATIC_ASSERT</a> (expr) |
| |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-EXTENSION:CAPS" title="G_GNUC_EXTENSION">G_GNUC_EXTENSION</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-CONST:CAPS" title="G_GNUC_CONST">G_GNUC_CONST</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-PURE:CAPS" title="G_GNUC_PURE">G_GNUC_PURE</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-MALLOC:CAPS" title="G_GNUC_MALLOC">G_GNUC_MALLOC</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-ALLOC-SIZE:CAPS" title="G_GNUC_ALLOC_SIZE()">G_GNUC_ALLOC_SIZE</a> (x) |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-ALLOC-SIZE2:CAPS" title="G_GNUC_ALLOC_SIZE2()">G_GNUC_ALLOC_SIZE2</a> (x, |
| y) |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-DEPRECATED:CAPS" title="G_GNUC_DEPRECATED">G_GNUC_DEPRECATED</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-NORETURN:CAPS" title="G_GNUC_NORETURN">G_GNUC_NORETURN</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-UNUSED:CAPS" title="G_GNUC_UNUSED">G_GNUC_UNUSED</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-PRINTF:CAPS" title="G_GNUC_PRINTF()">G_GNUC_PRINTF</a> (format_idx, |
| arg_idx) |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-SCANF:CAPS" title="G_GNUC_SCANF()">G_GNUC_SCANF</a> (format_idx, |
| arg_idx) |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-FORMAT:CAPS" title="G_GNUC_FORMAT()">G_GNUC_FORMAT</a> (arg_idx) |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-NULL-TERMINATED:CAPS" title="G_GNUC_NULL_TERMINATED">G_GNUC_NULL_TERMINATED</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-WARN-UNUSED-RESULT:CAPS" title="G_GNUC_WARN_UNUSED_RESULT">G_GNUC_WARN_UNUSED_RESULT</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-FUNCTION:CAPS" title="G_GNUC_FUNCTION">G_GNUC_FUNCTION</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-PRETTY-FUNCTION:CAPS" title="G_GNUC_PRETTY_FUNCTION">G_GNUC_PRETTY_FUNCTION</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-NO-INSTRUMENT:CAPS" title="G_GNUC_NO_INSTRUMENT">G_GNUC_NO_INSTRUMENT</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-HAVE-GNUC-VISIBILITY:CAPS" title="G_HAVE_GNUC_VISIBILITY">G_HAVE_GNUC_VISIBILITY</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-INTERNAL:CAPS" title="G_GNUC_INTERNAL">G_GNUC_INTERNAL</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-MAY-ALIAS:CAPS" title="G_GNUC_MAY_ALIAS">G_GNUC_MAY_ALIAS</a> |
| |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-LIKELY:CAPS" title="G_LIKELY()">G_LIKELY</a> (expr) |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-UNLIKELY:CAPS" title="G_UNLIKELY()">G_UNLIKELY</a> (expr) |
| |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-STRLOC:CAPS" title="G_STRLOC">G_STRLOC</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-STRFUNC:CAPS" title="G_STRFUNC">G_STRFUNC</a> |
| |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-MODIFIER:CAPS" title="G_GINT16_MODIFIER">G_GINT16_MODIFIER</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS" title="G_GINT16_FORMAT">G_GINT16_FORMAT</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GUINT16-FORMAT:CAPS" title="G_GUINT16_FORMAT">G_GUINT16_FORMAT</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT32-MODIFIER:CAPS" title="G_GINT32_MODIFIER">G_GINT32_MODIFIER</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT32-FORMAT:CAPS" title="G_GINT32_FORMAT">G_GINT32_FORMAT</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GUINT32-FORMAT:CAPS" title="G_GUINT32_FORMAT">G_GUINT32_FORMAT</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT64-MODIFIER:CAPS" title="G_GINT64_MODIFIER">G_GINT64_MODIFIER</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT64-FORMAT:CAPS" title="G_GINT64_FORMAT">G_GINT64_FORMAT</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GUINT64-FORMAT:CAPS" title="G_GUINT64_FORMAT">G_GUINT64_FORMAT</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GSIZE-MODIFIER:CAPS" title="G_GSIZE_MODIFIER">G_GSIZE_MODIFIER</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GSIZE-FORMAT:CAPS" title="G_GSIZE_FORMAT">G_GSIZE_FORMAT</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GSSIZE-FORMAT:CAPS" title="G_GSSIZE_FORMAT">G_GSSIZE_FORMAT</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GOFFSET-MODIFIER:CAPS" title="G_GOFFSET_MODIFIER">G_GOFFSET_MODIFIER</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GOFFSET-FORMAT:CAPS" title="G_GOFFSET_FORMAT">G_GOFFSET_FORMAT</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GINTPTR-MODIFIER:CAPS" title="G_GINTPTR_MODIFIER">G_GINTPTR_MODIFIER</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GINTPTR-FORMAT:CAPS" title="G_GINTPTR_FORMAT">G_GINTPTR_FORMAT</a> |
| #define <a class="link" href="glib-Miscellaneous-Macros.html#G-GUINTPTR-FORMAT:CAPS" title="G_GUINTPTR_FORMAT">G_GUINTPTR_FORMAT</a> |
| </pre> |
| </div> |
| <div class="refsect1" title="Description"> |
| <a name="glib-Miscellaneous-Macros.description"></a><h2>Description</h2> |
| <p> |
| These macros provide more specialized features which are not needed so often |
| by application programmers. |
| </p> |
| </div> |
| <div class="refsect1" title="Details"> |
| <a name="glib-Miscellaneous-Macros.details"></a><h2>Details</h2> |
| <div class="refsect2" title="G_INLINE_FUNC"> |
| <a name="G-INLINE-FUNC:CAPS"></a><h3>G_INLINE_FUNC</h3> |
| <pre class="programlisting">#define G_INLINE_FUNC</pre> |
| <p> |
| This macro is used to export function prototypes so they can be linked |
| with an external version when no inlining is performed. The file which |
| implements the functions should define <code class="literal">G_IMPLEMENTS_INLINES</code> |
| before including the headers which contain <a class="link" href="glib-Miscellaneous-Macros.html#G-INLINE-FUNC:CAPS" title="G_INLINE_FUNC"><code class="literal">G_INLINE_FUNC</code></a> declarations. |
| Since inlining is very compiler-dependent using these macros correctly |
| is very difficult. Their use is strongly discouraged. |
| </p> |
| <p> |
| This macro is often mistaken for a replacement for the inline keyword; |
| inline is already declared in a portable manner in the glib headers |
| and can be used normally. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_STMT_START"> |
| <a name="G-STMT-START:CAPS"></a><h3>G_STMT_START</h3> |
| <pre class="programlisting"># define G_STMT_START do |
| </pre> |
| <p> |
| Used within multi-statement macros so that they can be used in places where |
| only one statement is expected by the compiler. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_STMT_END"> |
| <a name="G-STMT-END:CAPS"></a><h3>G_STMT_END</h3> |
| <pre class="programlisting"># define G_STMT_END while (0) |
| </pre> |
| <p> |
| Used within multi-statement macros so that they can be used in places where |
| only one statement is expected by the compiler. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_BEGIN_DECLS"> |
| <a name="G-BEGIN-DECLS:CAPS"></a><h3>G_BEGIN_DECLS</h3> |
| <pre class="programlisting">#define G_BEGIN_DECLS</pre> |
| <p> |
| Used (along with <a class="link" href="glib-Miscellaneous-Macros.html#G-END-DECLS:CAPS" title="G_END_DECLS"><span class="type">G_END_DECLS</span></a>) to bracket header files. If the |
| compiler in use is a C++ compiler, adds <code class="literal">extern "C"</code> |
| around the header. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_END_DECLS"> |
| <a name="G-END-DECLS:CAPS"></a><h3>G_END_DECLS</h3> |
| <pre class="programlisting">#define G_END_DECLS</pre> |
| <p> |
| Used (along with <a class="link" href="glib-Miscellaneous-Macros.html#G-BEGIN-DECLS:CAPS" title="G_BEGIN_DECLS"><span class="type">G_BEGIN_DECLS</span></a>) to bracket header files. If the |
| compiler in use is a C++ compiler, adds <code class="literal">extern "C"</code> |
| around the header. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_N_ELEMENTS()"> |
| <a name="G-N-ELEMENTS:CAPS"></a><h3>G_N_ELEMENTS()</h3> |
| <pre class="programlisting">#define G_N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0])) |
| </pre> |
| <p> |
| Determines the number of elements in an array. The array must be |
| declared so the compiler knows its size at compile-time; this |
| macro will not work on an array allocated on the heap, only static |
| arrays or arrays on the stack. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>arr</code></em> :</span></p></td> |
| <td>the array |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_VA_COPY()"> |
| <a name="G-VA-COPY:CAPS"></a><h3>G_VA_COPY()</h3> |
| <pre class="programlisting">#define G_VA_COPY(ap1,ap2)</pre> |
| <p> |
| Portable way to copy <span class="type">va_list</span> variables. |
| </p> |
| <p> |
| In order to use this function, you must include <code class="filename">string.h</code> |
| yourself, because this macro may use <code class="function"><code class="function">memmove()</code></code> and GLib |
| does not include <code class="function">string.h</code> for you. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>ap1</code></em> :</span></p></td> |
| <td>the <span class="type">va_list</span> variable to place a copy of <em class="parameter"><code>ap2</code></em> in. |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>ap2</code></em> :</span></p></td> |
| <td>a <span class="type">va_list</span>. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_STRINGIFY()"> |
| <a name="G-STRINGIFY:CAPS"></a><h3>G_STRINGIFY()</h3> |
| <pre class="programlisting">#define G_STRINGIFY(macro_or_string) G_STRINGIFY_ARG (macro_or_string) |
| </pre> |
| <p> |
| Accepts a macro or a string and converts it into a string after |
| preprocessor argument expansion. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>macro_or_string</code></em> :</span></p></td> |
| <td>a macro or a string. |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_PASTE()"> |
| <a name="G-PASTE:CAPS"></a><h3>G_PASTE()</h3> |
| <pre class="programlisting">#define G_PASTE(identifier1,identifier2) G_PASTE_ARGS (identifier1, identifier2) |
| </pre> |
| <p> |
| Yields a new preprocessor pasted identifier 'identifier1identifier2' |
| from its expanded arguments 'identifier1' and 'identifier2'. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>identifier1</code></em> :</span></p></td> |
| <td>an identifier |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>identifier2</code></em> :</span></p></td> |
| <td>an identifier |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.20</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_PASTE_ARGS()"> |
| <a name="G-PASTE-ARGS:CAPS"></a><h3>G_PASTE_ARGS()</h3> |
| <pre class="programlisting">#define G_PASTE_ARGS(identifier1,identifier2) identifier1 ## identifier2 |
| </pre> |
| <p> |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>identifier1</code></em> :</span></p></td> |
| <td> |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>identifier2</code></em> :</span></p></td> |
| <td> |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_STATIC_ASSERT()"> |
| <a name="G-STATIC-ASSERT:CAPS"></a><h3>G_STATIC_ASSERT()</h3> |
| <pre class="programlisting">#define G_STATIC_ASSERT(expr) typedef struct { char Compile_Time_Assertion[(expr) ? 1 : -1]; } G_PASTE (_GStaticAssert_, __LINE__) |
| </pre> |
| <p> |
| The G_STATIC_ASSERT macro lets the programmer check a condition at compile time, |
| the condition needs to be compile time computable. |
| The macro can be used in any place where a <code class="literal">typedef</code> is valid. |
| The macro should only be used once per source code line. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>expr</code></em> :</span></p></td> |
| <td>a constant expression. |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.20</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GNUC_EXTENSION"> |
| <a name="G-GNUC-EXTENSION:CAPS"></a><h3>G_GNUC_EXTENSION</h3> |
| <pre class="programlisting">#define G_GNUC_EXTENSION</pre> |
| <p> |
| Expands to <code class="literal">__extension__</code> when <span class="command"><strong>gcc</strong></span> is |
| used as the compiler. |
| This simply tells <span class="command"><strong>gcc</strong></span> not to warn about the following non-standard code |
| when compiling with the <code class="option">-pedantic</code> option. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GNUC_CONST"> |
| <a name="G-GNUC-CONST:CAPS"></a><h3>G_GNUC_CONST</h3> |
| <pre class="programlisting">#define G_GNUC_CONST</pre> |
| <p> |
| Expands to the GNU C <code class="literal">const</code> function attribute if the compiler is |
| <span class="command"><strong>gcc</strong></span>. Declaring a function as const enables better optimization of calls |
| to the function. A const function doesn't examine any values except its parameters, and has no |
| effects except its return value. See the GNU C documentation for details. |
| </p> |
| <div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| <h3 class="title">Note</h3> |
| <p> |
| A function that has pointer arguments and examines the data pointed to |
| must <span class="emphasis"><em>not</em></span> be declared const. Likewise, a function that |
| calls a non-const function usually must not be const. It doesn't make sense |
| for a const function to return void. |
| </p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GNUC_PURE"> |
| <a name="G-GNUC-PURE:CAPS"></a><h3>G_GNUC_PURE</h3> |
| <pre class="programlisting">#define G_GNUC_PURE</pre> |
| <p> |
| Expands to the GNU C <code class="literal">pure</code> function attribute if the compiler is |
| <span class="command"><strong>gcc</strong></span>. Declaring a function as pure enables better optimization of |
| calls to the function. A pure function has no effects except its return value and the |
| return value depends only on the parameters and/or global variables. |
| See the GNU C documentation for details. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GNUC_MALLOC"> |
| <a name="G-GNUC-MALLOC:CAPS"></a><h3>G_GNUC_MALLOC</h3> |
| <pre class="programlisting">#define G_GNUC_MALLOC</pre> |
| <p> |
| Expands to the GNU C <code class="literal">malloc</code> function attribute if the |
| compiler is <span class="command"><strong>gcc</strong></span>. Declaring a function as malloc enables |
| better optimization of the function. A function can have the malloc attribute |
| if it returns a pointer which is guaranteed to not alias with any other pointer |
| when the function returns (in practice, this means newly allocated memory). |
| See the GNU C documentation for details. |
| </p> |
| <p class="since">Since 2.6</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GNUC_ALLOC_SIZE()"> |
| <a name="G-GNUC-ALLOC-SIZE:CAPS"></a><h3>G_GNUC_ALLOC_SIZE()</h3> |
| <pre class="programlisting">#define G_GNUC_ALLOC_SIZE(x)</pre> |
| <p> |
| Expands to the GNU C <code class="literal">alloc_size</code> function attribute if the |
| compiler is a new enough <span class="command"><strong>gcc</strong></span>. This attribute tells the |
| compiler that the function returns a pointer to memory of a size that is |
| specified by the <em class="parameter"><code>x</code></em>th function parameter. |
| See the GNU C documentation for details. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td> |
| <td>the index of the argument specifying the allocation size |
| </td> |
| </tr></tbody> |
| </table></div> |
| <p class="since">Since 2.18</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GNUC_ALLOC_SIZE2()"> |
| <a name="G-GNUC-ALLOC-SIZE2:CAPS"></a><h3>G_GNUC_ALLOC_SIZE2()</h3> |
| <pre class="programlisting">#define G_GNUC_ALLOC_SIZE2(x,y)</pre> |
| <p> |
| Expands to the GNU C <code class="literal">alloc_size</code> function attribute if the |
| compiler is a new enough <span class="command"><strong>gcc</strong></span>. This attribute tells the |
| compiler that the function returns a pointer to memory of a size that is |
| specified by the product of two function parameters. |
| See the GNU C documentation for details. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>x</code></em> :</span></p></td> |
| <td>the index of the argument specifying one factor of the allocation size |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>y</code></em> :</span></p></td> |
| <td>the index of the argument specifying the second factor of the allocation size |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.18</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GNUC_DEPRECATED"> |
| <a name="G-GNUC-DEPRECATED:CAPS"></a><h3>G_GNUC_DEPRECATED</h3> |
| <pre class="programlisting">#define G_GNUC_DEPRECATED</pre> |
| <p> |
| Expands to the GNU C <code class="literal">deprecated</code> attribute if the compiler |
| is <span class="command"><strong>gcc</strong></span>. |
| It can be used to mark typedefs, variables and functions as deprecated. |
| When called with the <code class="option">-Wdeprecated-declarations</code> option, the compiler will |
| generate warnings when deprecated interfaces are used. |
| See the GNU C documentation for details. |
| </p> |
| <p class="since">Since 2.2</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GNUC_NORETURN"> |
| <a name="G-GNUC-NORETURN:CAPS"></a><h3>G_GNUC_NORETURN</h3> |
| <pre class="programlisting">#define G_GNUC_NORETURN</pre> |
| <p> |
| Expands to the GNU C <code class="literal">noreturn</code> function attribute if the |
| compiler is <span class="command"><strong>gcc</strong></span>. It is used for declaring functions which never return. |
| It enables optimization of the function, and avoids possible compiler |
| warnings. See the GNU C documentation for details. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GNUC_UNUSED"> |
| <a name="G-GNUC-UNUSED:CAPS"></a><h3>G_GNUC_UNUSED</h3> |
| <pre class="programlisting">#define G_GNUC_UNUSED</pre> |
| <p> |
| Expands to the GNU C <code class="literal">unused</code> function attribute if the compiler is |
| <span class="command"><strong>gcc</strong></span>. It is used for declaring functions which may never be used. |
| It avoids possible compiler warnings. See the GNU C documentation for details. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GNUC_PRINTF()"> |
| <a name="G-GNUC-PRINTF:CAPS"></a><h3>G_GNUC_PRINTF()</h3> |
| <pre class="programlisting">#define G_GNUC_PRINTF( format_idx, arg_idx )</pre> |
| <p> |
| Expands to the GNU C <code class="literal">format</code> function attribute if the compiler is |
| <span class="command"><strong>gcc</strong></span>. This is used for declaring functions which take a variable number of |
| arguments, with the same syntax as <code class="function"><code class="function">printf()</code></code>. |
| It allows the compiler to type-check the arguments passed to the function. |
| See the GNU C documentation for details. |
| </p> |
| <div class="informalexample"> |
| <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td class="listing_lines" align="right"><pre>1 |
| 2 |
| 3 |
| 4</pre></td> |
| <td class="listing_code"><pre class="programlisting"><span class="normal"><a href="glib-Basic-Types.html#gint">gint</a> </span><span class="function"><a href="glib-String-Utility-Functions.html#g-snprintf">g_snprintf</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Basic-Types.html#gchar">gchar</a> </span><span class="symbol">*</span><span class="normal">string</span><span class="symbol">,</span> |
| <span class="normal"> <a href="glib-Basic-Types.html#gulong">gulong</a> n</span><span class="symbol">,</span> |
| <span class="normal"> <a href="glib-Basic-Types.html#gchar">gchar</a> </span><span class="keyword">const</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">format</span><span class="symbol">,</span> |
| <span class="normal"> </span><span class="symbol">...)</span><span class="normal"> </span><span class="function"><a href="glib-Miscellaneous-Macros.html#G-GNUC-PRINTF:CAPS">G_GNUC_PRINTF</a></span><span class="normal"> </span><span class="symbol">(</span><span class="number">3</span><span class="symbol">,</span><span class="normal"> </span><span class="number">4</span><span class="symbol">);</span></pre></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>format_idx</code></em> :</span></p></td> |
| <td>the index of the argument corresponding to the format string. |
| (The arguments are numbered from 1). |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>arg_idx</code></em> :</span></p></td> |
| <td>the index of the first of the format arguments. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GNUC_SCANF()"> |
| <a name="G-GNUC-SCANF:CAPS"></a><h3>G_GNUC_SCANF()</h3> |
| <pre class="programlisting">#define G_GNUC_SCANF( format_idx, arg_idx )</pre> |
| <p> |
| Expands to the GNU C <code class="literal">format</code> function attribute if the compiler is <span class="command"><strong>gcc</strong></span>. |
| This is used for declaring functions which take a variable number of |
| arguments, with the same syntax as <code class="function"><code class="function">scanf()</code></code>. |
| It allows the compiler to type-check the arguments passed to the function. |
| See the GNU C documentation for details. |
| </p> |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>format_idx</code></em> :</span></p></td> |
| <td>the index of the argument corresponding to the format string. |
| (The arguments are numbered from 1). |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>arg_idx</code></em> :</span></p></td> |
| <td>the index of the first of the format arguments. |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GNUC_FORMAT()"> |
| <a name="G-GNUC-FORMAT:CAPS"></a><h3>G_GNUC_FORMAT()</h3> |
| <pre class="programlisting">#define G_GNUC_FORMAT( arg_idx )</pre> |
| <p> |
| Expands to the GNU C <code class="literal">format_arg</code> function attribute if the compiler is <span class="command"><strong>gcc</strong></span>. |
| This function attribute specifies that a function takes a format |
| string for a <code class="function"><code class="function">printf()</code></code>, <code class="function"><code class="function">scanf()</code></code>, |
| <code class="function"><code class="function">strftime()</code></code> or <code class="function"><code class="function">strfmon()</code></code> style |
| function and modifies it, so that the result can be passed to a |
| <code class="function"><code class="function">printf()</code></code>, <code class="function"><code class="function">scanf()</code></code>, |
| <code class="function"><code class="function">strftime()</code></code> or <code class="function"><code class="function">strfmon()</code></code> style |
| function (with the remaining arguments to the format function the same as |
| they would have been for the unmodified string). |
| See the GNU C documentation for details. |
| </p> |
| <div class="informalexample"> |
| <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td class="listing_lines" align="right"><pre>1</pre></td> |
| <td class="listing_code"><pre class="programlisting"><span class="normal"><a href="glib-Basic-Types.html#gchar">gchar</a> </span><span class="symbol">*</span><span class="function"><a href="glib-I18N.html#g-dgettext">g_dgettext</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal"><a href="glib-Basic-Types.html#gchar">gchar</a> </span><span class="symbol">*</span><span class="normal">domain_name</span><span class="symbol">,</span><span class="normal"> <a href="glib-Basic-Types.html#gchar">gchar</a> </span><span class="symbol">*</span><span class="normal">msgid</span><span class="symbol">)</span><span class="normal"> </span><span class="function"><a href="glib-Miscellaneous-Macros.html#G-GNUC-FORMAT:CAPS">G_GNUC_FORMAT</a></span><span class="normal"> </span><span class="symbol">(</span><span class="number">2</span><span class="symbol">);</span></pre></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody><tr> |
| <td><p><span class="term"><em class="parameter"><code>arg_idx</code></em> :</span></p></td> |
| <td>the index of the argument. |
| </td> |
| </tr></tbody> |
| </table></div> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GNUC_NULL_TERMINATED"> |
| <a name="G-GNUC-NULL-TERMINATED:CAPS"></a><h3>G_GNUC_NULL_TERMINATED</h3> |
| <pre class="programlisting">#define G_GNUC_NULL_TERMINATED</pre> |
| <p> |
| Expands to the GNU C <code class="literal">sentinel</code> function attribute if the |
| compiler is <span class="command"><strong>gcc</strong></span>, or "" if it isn't. This function attribute |
| only applies to variadic functions and instructs the compiler to check that |
| the argument list is terminated with an explicit <a class="link" href="glib-Standard-Macros.html#NULL:CAPS" title="NULL"><code class="literal">NULL</code></a>. |
| See the GNU C documentation for details. |
| </p> |
| Since: 2.8</div> |
| <hr> |
| <div class="refsect2" title="G_GNUC_WARN_UNUSED_RESULT"> |
| <a name="G-GNUC-WARN-UNUSED-RESULT:CAPS"></a><h3>G_GNUC_WARN_UNUSED_RESULT</h3> |
| <pre class="programlisting">#define G_GNUC_WARN_UNUSED_RESULT</pre> |
| <p> |
| Expands to the GNU C <code class="literal">warn_unused_result</code> function attribute |
| if the compiler is <span class="command"><strong>gcc</strong></span>, or "" if it isn't. This function |
| attribute makes the compiler emit a warning if the result of a function call |
| is ignored. See the GNU C documentation for details. |
| </p> |
| <p class="since">Since 2.10</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GNUC_FUNCTION"> |
| <a name="G-GNUC-FUNCTION:CAPS"></a><h3>G_GNUC_FUNCTION</h3> |
| <pre class="programlisting">#define G_GNUC_FUNCTION</pre> |
| <div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| <h3 class="title">Warning</h3> |
| <p><code class="literal">G_GNUC_FUNCTION</code> has been deprecated since version 2.16 and should not be used in newly-written code. Use <a class="link" href="glib-Miscellaneous-Macros.html#G-STRFUNC:CAPS" title="G_STRFUNC"><span class="type">G_STRFUNC</span></a> instead.</p> |
| </div> |
| <p> |
| Expands to "" on all modern compilers, and to <code class="literal">__FUNCTION__</code> |
| on <span class="command"><strong>gcc</strong></span> version 2.x. Don't use it. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GNUC_PRETTY_FUNCTION"> |
| <a name="G-GNUC-PRETTY-FUNCTION:CAPS"></a><h3>G_GNUC_PRETTY_FUNCTION</h3> |
| <pre class="programlisting">#define G_GNUC_PRETTY_FUNCTION</pre> |
| <div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| <h3 class="title">Warning</h3> |
| <p><code class="literal">G_GNUC_PRETTY_FUNCTION</code> has been deprecated since version 2.16 and should not be used in newly-written code. Use <a class="link" href="glib-Miscellaneous-Macros.html#G-STRFUNC:CAPS" title="G_STRFUNC"><span class="type">G_STRFUNC</span></a> instead.</p> |
| </div> |
| <p> |
| Expands to "" on all modern compilers, and to |
| <code class="literal">__PRETTY_FUNCTION__</code> on <span class="command"><strong>gcc</strong></span> version 2.x. |
| Don't use it. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GNUC_NO_INSTRUMENT"> |
| <a name="G-GNUC-NO-INSTRUMENT:CAPS"></a><h3>G_GNUC_NO_INSTRUMENT</h3> |
| <pre class="programlisting">#define G_GNUC_NO_INSTRUMENT</pre> |
| <p> |
| Expands to the GNU C <code class="literal">no_instrument_function</code> function |
| attribute if the compiler is <span class="command"><strong>gcc</strong></span>. Functions with this |
| attribute will not be |
| instrumented for profiling, when the compiler is called with the |
| <code class="option">-finstrument-functions</code> option. |
| See the GNU C documentation for details. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_HAVE_GNUC_VISIBILITY"> |
| <a name="G-HAVE-GNUC-VISIBILITY:CAPS"></a><h3>G_HAVE_GNUC_VISIBILITY</h3> |
| <pre class="programlisting">#define G_HAVE_GNUC_VISIBILITY 1 |
| </pre> |
| <p> |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GNUC_INTERNAL"> |
| <a name="G-GNUC-INTERNAL:CAPS"></a><h3>G_GNUC_INTERNAL</h3> |
| <pre class="programlisting">#define G_GNUC_INTERNAL</pre> |
| <p> |
| This attribute can be used for marking library functions as being used |
| internally to the library only, which may allow the compiler to handle |
| function calls more efficiently. |
| Note that static functions do not need to be marked as internal in this way. |
| See the GNU C documentation for details. |
| </p> |
| <p> |
| When using a compiler that supports the GNU C hidden visibility attribute, |
| this macro expands to <code class="literal">__attribute__((visibility("hidden")))</code>. |
| When using the Sun Studio compiler, it expands to <code class="literal">__hidden</code>. |
| </p> |
| <p> |
| Note that for portability, the attribute should be placed before the |
| function declaration. While GCC allows the macro after the declaration, |
| Sun Studio does not. |
| </p> |
| <div class="informalexample"> |
| <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td class="listing_lines" align="right"><pre>1 |
| 2 |
| 3 |
| 4 |
| 5</pre></td> |
| <td class="listing_code"><pre class="programlisting"><span class="normal"><a href="glib-Miscellaneous-Macros.html#G-GNUC-INTERNAL:CAPS">G_GNUC_INTERNAL</a></span> |
| <span class="type">void</span><span class="normal"> </span><span class="function">_g_log_fallback_handler</span><span class="normal"> </span><span class="symbol">(</span><span class="keyword">const</span><span class="normal"> <a href="glib-Basic-Types.html#gchar">gchar</a> </span><span class="symbol">*</span><span class="normal">log_domain</span><span class="symbol">,</span> |
| <span class="normal"> <a href="glib-Message-Logging.html#GLogLevelFlags">GLogLevelFlags</a> log_level</span><span class="symbol">,</span> |
| <span class="normal"> </span><span class="keyword">const</span><span class="normal"> <a href="glib-Basic-Types.html#gchar">gchar</a> </span><span class="symbol">*</span><span class="normal">message</span><span class="symbol">,</span> |
| <span class="normal"> <a href="glib-Basic-Types.html#gpointer">gpointer</a> unused_data</span><span class="symbol">);</span></pre></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| Since: 2.6</div> |
| <hr> |
| <div class="refsect2" title="G_GNUC_MAY_ALIAS"> |
| <a name="G-GNUC-MAY-ALIAS:CAPS"></a><h3>G_GNUC_MAY_ALIAS</h3> |
| <pre class="programlisting">#define G_GNUC_MAY_ALIAS</pre> |
| <p> |
| Expands to the GNU C <code class="literal">may_alias</code> type attribute |
| if the compiler is <span class="command"><strong>gcc</strong></span>. Types with this attribute |
| will not be subjected to type-based alias analysis, but are assumed |
| to alias with any other type, just like char. |
| See the GNU C documentation for details. |
| </p> |
| Since: 2.14</div> |
| <hr> |
| <div class="refsect2" title="G_LIKELY()"> |
| <a name="G-LIKELY:CAPS"></a><h3>G_LIKELY()</h3> |
| <pre class="programlisting">#define G_LIKELY(expr)</pre> |
| <p> |
| Hints the compiler that the expression is likely to evaluate to a true |
| value. The compiler may use this information for optimizations. |
| </p> |
| <div class="informalexample"> |
| <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td class="listing_lines" align="right"><pre>1 |
| 2</pre></td> |
| <td class="listing_code"><pre class="programlisting"><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="function"><a href="glib-Miscellaneous-Macros.html#G-LIKELY:CAPS">G_LIKELY</a></span><span class="normal"> </span><span class="symbol">(</span><span class="function">random</span><span class="normal"> </span><span class="symbol">()</span><span class="normal"> </span><span class="symbol">!=</span><span class="normal"> </span><span class="number">1</span><span class="symbol">))</span> |
| <span class="normal"> </span><span class="function"><a href="glib-Warnings-and-Assertions.html#g-print">g_print</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"not one"</span><span class="symbol">);</span></pre></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>expr</code></em> :</span></p></td> |
| <td>the expression |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td>the value of <em class="parameter"><code>expr</code></em> |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.2</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_UNLIKELY()"> |
| <a name="G-UNLIKELY:CAPS"></a><h3>G_UNLIKELY()</h3> |
| <pre class="programlisting">#define G_UNLIKELY(expr)</pre> |
| <p> |
| Hints the compiler that the expression is unlikely to evaluate to a true |
| value. The compiler may use this information for optimizations. |
| </p> |
| <div class="informalexample"> |
| <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td class="listing_lines" align="right"><pre>1 |
| 2</pre></td> |
| <td class="listing_code"><pre class="programlisting"><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="function"><a href="glib-Miscellaneous-Macros.html#G-UNLIKELY:CAPS">G_UNLIKELY</a></span><span class="normal"> </span><span class="symbol">(</span><span class="function">random</span><span class="normal"> </span><span class="symbol">()</span><span class="normal"> </span><span class="symbol">==</span><span class="normal"> </span><span class="number">1</span><span class="symbol">))</span> |
| <span class="normal"> </span><span class="function"><a href="glib-Warnings-and-Assertions.html#g-print">g_print</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"a random one"</span><span class="symbol">);</span></pre></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| <div class="variablelist"><table border="0"> |
| <col align="left" valign="top"> |
| <tbody> |
| <tr> |
| <td><p><span class="term"><em class="parameter"><code>expr</code></em> :</span></p></td> |
| <td>the expression |
| </td> |
| </tr> |
| <tr> |
| <td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td> |
| <td>the value of <em class="parameter"><code>expr</code></em> |
| </td> |
| </tr> |
| </tbody> |
| </table></div> |
| <p class="since">Since 2.2</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_STRLOC"> |
| <a name="G-STRLOC:CAPS"></a><h3>G_STRLOC</h3> |
| <pre class="programlisting">#define G_STRLOC</pre> |
| <p> |
| Expands to a string identifying the current code position. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_STRFUNC"> |
| <a name="G-STRFUNC:CAPS"></a><h3>G_STRFUNC</h3> |
| <pre class="programlisting">#define G_STRFUNC</pre> |
| <p> |
| Expands to a string identifying the current function. |
| </p> |
| <p class="since">Since 2.4</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GINT16_MODIFIER"> |
| <a name="G-GINT16-MODIFIER:CAPS"></a><h3>G_GINT16_MODIFIER</h3> |
| <pre class="programlisting">#define G_GINT16_MODIFIER "h" |
| </pre> |
| <p> |
| The platform dependent length modifier for conversion specifiers for scanning |
| and printing values of type <a class="link" href="glib-Basic-Types.html#gint16" title="gint16"><span class="type">gint16</span></a> or <a class="link" href="glib-Basic-Types.html#guint16" title="guint16"><span class="type">guint16</span></a>. It is a string literal, |
| but doesn't include the percent-sign, such that you can add precision and |
| length modifiers between percent-sign and conversion specifier and append a |
| conversion specifier. |
| </p> |
| <p> |
| The following example prints "0x7b"; |
| </p> |
| <div class="informalexample"> |
| <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td class="listing_lines" align="right"><pre>1 |
| 2</pre></td> |
| <td class="listing_code"><pre class="programlisting"><span class="normal"><a href="glib-Basic-Types.html#gint16">gint16</a> value </span><span class="symbol">=</span><span class="normal"> </span><span class="number">123</span><span class="symbol">;</span> |
| <span class="function"><a href="glib-Warnings-and-Assertions.html#g-print">g_print</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"%#"</span><span class="normal"> <a href="glib-Miscellaneous-Macros.html#G-GINT16-MODIFIER:CAPS">G_GINT16_MODIFIER</a> </span><span class="string">"x"</span><span class="symbol">,</span><span class="normal"> value</span><span class="symbol">);</span></pre></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| <p> |
| </p> |
| <p class="since">Since 2.4</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GINT16_FORMAT"> |
| <a name="G-GINT16-FORMAT:CAPS"></a><h3>G_GINT16_FORMAT</h3> |
| <pre class="programlisting">#define G_GINT16_FORMAT "hi" |
| </pre> |
| <p> |
| This is the platform dependent conversion specifier for scanning and |
| printing values of type <a class="link" href="glib-Basic-Types.html#gint16" title="gint16"><span class="type">gint16</span></a>. It is a string literal, but doesn't |
| include the percent-sign, such that you can add precision and length |
| modifiers between percent-sign and conversion specifier. |
| </p> |
| <p> |
| </p> |
| <div class="informalexample"> |
| <table class="listing_frame" border="0" cellpadding="0" cellspacing="0"> |
| <tbody> |
| <tr> |
| <td class="listing_lines" align="right"><pre>1 |
| 2 |
| 3 |
| 4 |
| 5</pre></td> |
| <td class="listing_code"><pre class="programlisting"><span class="normal"><a href="glib-Basic-Types.html#gint16">gint16</a> in</span><span class="symbol">;</span> |
| <span class="normal"><a href="glib-Basic-Types.html#gint32">gint32</a> out</span><span class="symbol">;</span> |
| <span class="function">sscanf</span><span class="normal"> </span><span class="symbol">(</span><span class="string">"42"</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"%"</span><span class="normal"> <a href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS">G_GINT16_FORMAT</a></span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">&</span><span class="normal">in</span><span class="symbol">)</span> |
| <span class="normal">out </span><span class="symbol">=</span><span class="normal"> in </span><span class="symbol">*</span><span class="normal"> </span><span class="number">1000</span><span class="symbol">;</span> |
| <span class="function"><a href="glib-Warnings-and-Assertions.html#g-print">g_print</a></span><span class="normal"> </span><span class="symbol">(</span><span class="string">"%"</span><span class="normal"> <a href="glib-Miscellaneous-Macros.html#G-GINT32-FORMAT:CAPS">G_GINT32_FORMAT</a></span><span class="symbol">,</span><span class="normal"> out</span><span class="symbol">);</span></pre></td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| |
| <p> |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GUINT16_FORMAT"> |
| <a name="G-GUINT16-FORMAT:CAPS"></a><h3>G_GUINT16_FORMAT</h3> |
| <pre class="programlisting">#define G_GUINT16_FORMAT "hu" |
| </pre> |
| <p> |
| This is the platform dependent conversion specifier for scanning and |
| printing values of type <a class="link" href="glib-Basic-Types.html#guint16" title="guint16"><span class="type">guint16</span></a>. See also <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS" title="G_GINT16_FORMAT"><span class="type">G_GINT16_FORMAT</span></a>. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GINT32_MODIFIER"> |
| <a name="G-GINT32-MODIFIER:CAPS"></a><h3>G_GINT32_MODIFIER</h3> |
| <pre class="programlisting">#define G_GINT32_MODIFIER "" |
| </pre> |
| <p> |
| The platform dependent length modifier for conversion specifiers for scanning |
| and printing values of type <a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="type">gint32</span></a> or <a class="link" href="glib-Basic-Types.html#guint32" title="guint32"><span class="type">guint32</span></a>. It is a string literal, |
| See also <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-MODIFIER:CAPS" title="G_GINT16_MODIFIER"><span class="type">G_GINT16_MODIFIER</span></a>. |
| </p> |
| <p class="since">Since 2.4</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GINT32_FORMAT"> |
| <a name="G-GINT32-FORMAT:CAPS"></a><h3>G_GINT32_FORMAT</h3> |
| <pre class="programlisting">#define G_GINT32_FORMAT "i" |
| </pre> |
| <p> |
| This is the platform dependent conversion specifier for scanning and |
| printing values of type <a class="link" href="glib-Basic-Types.html#gint32" title="gint32"><span class="type">gint32</span></a>. See also <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS" title="G_GINT16_FORMAT"><span class="type">G_GINT16_FORMAT</span></a>. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GUINT32_FORMAT"> |
| <a name="G-GUINT32-FORMAT:CAPS"></a><h3>G_GUINT32_FORMAT</h3> |
| <pre class="programlisting">#define G_GUINT32_FORMAT "u" |
| </pre> |
| <p> |
| This is the platform dependent conversion specifier for scanning and |
| printing values of type <a class="link" href="glib-Basic-Types.html#guint32" title="guint32"><span class="type">guint32</span></a>. See also <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS" title="G_GINT16_FORMAT"><span class="type">G_GINT16_FORMAT</span></a>. |
| </p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GINT64_MODIFIER"> |
| <a name="G-GINT64-MODIFIER:CAPS"></a><h3>G_GINT64_MODIFIER</h3> |
| <pre class="programlisting">#define G_GINT64_MODIFIER "l" |
| </pre> |
| <p> |
| The platform dependent length modifier for conversion specifiers for scanning |
| and printing values of type <a class="link" href="glib-Basic-Types.html#gint64" title="gint64"><span class="type">gint64</span></a> or <a class="link" href="glib-Basic-Types.html#guint64" title="guint64"><span class="type">guint64</span></a>. It is a string literal. |
| </p> |
| <div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| <h3 class="title">Note</h3> |
| <p> |
| Some platforms do not support printing 64 bit integers, |
| even though the types are supported. On such platforms <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT64-MODIFIER:CAPS" title="G_GINT64_MODIFIER"><span class="type">G_GINT64_MODIFIER</span></a> |
| is not defined. |
| </p> |
| </div> |
| <p class="since">Since 2.4</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GINT64_FORMAT"> |
| <a name="G-GINT64-FORMAT:CAPS"></a><h3>G_GINT64_FORMAT</h3> |
| <pre class="programlisting">#define G_GINT64_FORMAT "li" |
| </pre> |
| <p> |
| This is the platform dependent conversion specifier for scanning and |
| printing values of type <a class="link" href="glib-Basic-Types.html#gint64" title="gint64"><span class="type">gint64</span></a>. See also <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS" title="G_GINT16_FORMAT"><span class="type">G_GINT16_FORMAT</span></a>. |
| </p> |
| <div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| <h3 class="title">Note</h3> |
| <p> |
| Some platforms do not support scanning and printing 64 bit integers, |
| even though the types are supported. On such platforms <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT64-FORMAT:CAPS" title="G_GINT64_FORMAT"><span class="type">G_GINT64_FORMAT</span></a> |
| is not defined. Note that <code class="function">scanf()</code> may not support 64 bit integers, even |
| if <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT64-FORMAT:CAPS" title="G_GINT64_FORMAT"><span class="type">G_GINT64_FORMAT</span></a> is defined. Due to its weak error handling, <code class="function">scanf()</code> |
| is not recommended for parsing anyway; consider using <a class="link" href="glib-String-Utility-Functions.html#g-ascii-strtoull" title="g_ascii_strtoull ()"><code class="function">g_ascii_strtoull()</code></a> |
| instead. |
| </p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GUINT64_FORMAT"> |
| <a name="G-GUINT64-FORMAT:CAPS"></a><h3>G_GUINT64_FORMAT</h3> |
| <pre class="programlisting">#define G_GUINT64_FORMAT "lu" |
| </pre> |
| <p> |
| This is the platform dependent conversion specifier for scanning and |
| printing values of type <a class="link" href="glib-Basic-Types.html#guint64" title="guint64"><span class="type">guint64</span></a>. See also <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS" title="G_GINT16_FORMAT"><span class="type">G_GINT16_FORMAT</span></a>. |
| </p> |
| <div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"> |
| <h3 class="title">Note</h3> |
| <p> |
| Some platforms do not support scanning and printing 64 bit integers, |
| even though the types are supported. On such platforms <a class="link" href="glib-Miscellaneous-Macros.html#G-GUINT64-FORMAT:CAPS" title="G_GUINT64_FORMAT"><span class="type">G_GUINT64_FORMAT</span></a> |
| is not defined. Note that <code class="function">scanf()</code> may not support 64 bit integers, even |
| if <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT64-FORMAT:CAPS" title="G_GINT64_FORMAT"><span class="type">G_GINT64_FORMAT</span></a> is defined. Due to its weak error handling, <code class="function">scanf()</code> is not |
| recommended for parsing anyway; consider using <code class="function">g_strtoull()</code> instead. |
| </p> |
| </div> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GSIZE_MODIFIER"> |
| <a name="G-GSIZE-MODIFIER:CAPS"></a><h3>G_GSIZE_MODIFIER</h3> |
| <pre class="programlisting">#define G_GSIZE_MODIFIER "l" |
| </pre> |
| <p> |
| The platform dependent length modifier for conversion specifiers for scanning |
| and printing values of type <a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="type">gsize</span></a> or <a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="type">gssize</span></a>. It is a string literal, |
| </p> |
| <p class="since">Since 2.6</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GSIZE_FORMAT"> |
| <a name="G-GSIZE-FORMAT:CAPS"></a><h3>G_GSIZE_FORMAT</h3> |
| <pre class="programlisting">#define G_GSIZE_FORMAT "lu" |
| </pre> |
| <p> |
| This is the platform dependent conversion specifier for scanning and |
| printing values of type <a class="link" href="glib-Basic-Types.html#gsize" title="gsize"><span class="type">gsize</span></a>. See also <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS" title="G_GINT16_FORMAT"><span class="type">G_GINT16_FORMAT</span></a>. |
| </p> |
| <p class="since">Since 2.6</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GSSIZE_FORMAT"> |
| <a name="G-GSSIZE-FORMAT:CAPS"></a><h3>G_GSSIZE_FORMAT</h3> |
| <pre class="programlisting">#define G_GSSIZE_FORMAT "li" |
| </pre> |
| <p> |
| This is the platform dependent conversion specifier for scanning and |
| printing values of type <a class="link" href="glib-Basic-Types.html#gssize" title="gssize"><span class="type">gssize</span></a>. See also <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS" title="G_GINT16_FORMAT"><span class="type">G_GINT16_FORMAT</span></a>. |
| </p> |
| <p class="since">Since 2.6</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GOFFSET_MODIFIER"> |
| <a name="G-GOFFSET-MODIFIER:CAPS"></a><h3>G_GOFFSET_MODIFIER</h3> |
| <pre class="programlisting">#define G_GOFFSET_MODIFIER G_GINT64_MODIFIER |
| </pre> |
| <p> |
| The platform dependent length modifier for conversion specifiers for scanning |
| and printing values of type <a class="link" href="glib-Basic-Types.html#goffset" title="goffset"><span class="type">goffset</span></a>. It is a string literal. See also |
| <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT64-MODIFIER:CAPS" title="G_GINT64_MODIFIER"><span class="type">G_GINT64_MODIFIER</span></a>. |
| </p> |
| <p class="since">Since 2.20</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GOFFSET_FORMAT"> |
| <a name="G-GOFFSET-FORMAT:CAPS"></a><h3>G_GOFFSET_FORMAT</h3> |
| <pre class="programlisting">#define G_GOFFSET_FORMAT G_GINT64_FORMAT |
| </pre> |
| <p> |
| This is the platform dependent conversion specifier for scanning and |
| printing values of type <a class="link" href="glib-Basic-Types.html#goffset" title="goffset"><span class="type">goffset</span></a>. See also <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT64-FORMAT:CAPS" title="G_GINT64_FORMAT"><span class="type">G_GINT64_FORMAT</span></a>. |
| </p> |
| Since: 2.20</div> |
| <hr> |
| <div class="refsect2" title="G_GINTPTR_MODIFIER"> |
| <a name="G-GINTPTR-MODIFIER:CAPS"></a><h3>G_GINTPTR_MODIFIER</h3> |
| <pre class="programlisting">#define G_GINTPTR_MODIFIER "l" |
| </pre> |
| <p> |
| The platform dependent length modifier for conversion specifiers for scanning |
| and printing values of type <a class="link" href="glib-Basic-Types.html#gintptr" title="gintptr"><span class="type">gintptr</span></a> or <a class="link" href="glib-Basic-Types.html#guintptr" title="guintptr"><span class="type">guintptr</span></a>. It is a string literal. |
| </p> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GINTPTR_FORMAT"> |
| <a name="G-GINTPTR-FORMAT:CAPS"></a><h3>G_GINTPTR_FORMAT</h3> |
| <pre class="programlisting">#define G_GINTPTR_FORMAT "li" |
| </pre> |
| <p> |
| This is the platform dependent conversion specifier for scanning and |
| printing values of type <a class="link" href="glib-Basic-Types.html#gintptr" title="gintptr"><span class="type">gintptr</span></a>. |
| </p> |
| <p class="since">Since 2.22</p> |
| </div> |
| <hr> |
| <div class="refsect2" title="G_GUINTPTR_FORMAT"> |
| <a name="G-GUINTPTR-FORMAT:CAPS"></a><h3>G_GUINTPTR_FORMAT</h3> |
| <pre class="programlisting">#define G_GUINTPTR_FORMAT "lu" |
| </pre> |
| <p> |
| This is the platform dependent conversion specifier for scanning and |
| printing values of type <a class="link" href="glib-Basic-Types.html#guintptr" title="guintptr"><span class="type">guintptr</span></a>. |
| </p> |
| <p class="since">Since 2.22</p> |
| </div> |
| </div> |
| </div> |
| <div class="footer"> |
| <hr> |
| Generated by GTK-Doc V1.14</div> |
| </body> |
| </html> |