📄 glib-miscellaneous-macros.html
字号:
<a class="indexterm" name="id2846804"></a><pre class="programlisting">if G_LIKELY ();</pre><p>Hints the compiler that the expression is likely to evaluate to a truevalue. The compiler may use this information for optimizations.</p><div class="informalexample"><pre class="programlisting">if (G_LIKELY (random () != 1)) g_print ("not one");</pre></div><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><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" lang="en"><a name="id2846861"></a><h3><a name="G-UNLIKELY:CAPS"></a>G_UNLIKELY()</h3><a class="indexterm" name="id2846876"></a><pre class="programlisting">#define G_UNLIKELY(expr)</pre><p>Hints the compiler that the expression is unlikely to evaluate to a truevalue. The compiler may use this information for optimizations.</p><div class="informalexample"><pre class="programlisting">if (G_UNLIKELY (random () == 1)) g_print ("a random one");</pre></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" lang="en"><a name="id2846943"></a><h3><a name="G-STRLOC:CAPS"></a>G_STRLOC</h3><a class="indexterm" name="id2846956"></a><pre class="programlisting">#define G_STRLOC</pre><p>Expands to a string identifying the current code position. </p></div><hr><div class="refsect2" lang="en"><a name="id2846972"></a><h3><a name="G-STRFUNC:CAPS"></a>G_STRFUNC</h3><a class="indexterm" name="id2846986"></a><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" lang="en"><a name="id2847009"></a><h3><a name="G-GINT16-MODIFIER:CAPS"></a>G_GINT16_MODIFIER</h3><a class="indexterm" name="id2847025"></a><pre class="programlisting">#define G_GINT16_MODIFIER "h"</pre><p>The platform dependent length modifier for constructing <code class="function">printf()</code> conversionspecifiers for values of type <a class="link" href="glib-Basic-Types.html#gint16"><span class="type">gint16</span></a> or <a class="link" href="glib-Basic-Types.html#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"><pre class="programlisting">gint16 value = 123;g_print ("%#" G_GINT16_MODIFIER "x", value);</pre></div><p></p><p class="since">Since 2.4</p></div><hr><div class="refsect2" lang="en"><a name="id2847092"></a><h3><a name="G-GINT16-FORMAT:CAPS"></a>G_GINT16_FORMAT</h3><a class="indexterm" name="id2847106"></a><pre class="programlisting">#define G_GINT16_FORMAT "hi"</pre><p>This is the platform dependent conversion specifier for scanning andprinting values of type <a class="link" href="glib-Basic-Types.html#gint16"><span class="type">gint16</span></a>. It is a string literal, but doesn'tinclude the percent-sign, such that you can add precision and lengthmodifiers between percent-sign and conversion specifier.</p><p></p><div class="informalexample"><pre class="programlisting">gint16 in;gint32 out;sscanf ("42", "%" G_GINT16_FORMAT, &in)out = in * 1000;g_print ("%" G_GINT32_FORMAT, out);</pre></div><p></p></div><hr><div class="refsect2" lang="en"><a name="id2847147"></a><h3><a name="G-GUINT16-FORMAT:CAPS"></a>G_GUINT16_FORMAT</h3><a class="indexterm" name="id2847161"></a><pre class="programlisting">#define G_GUINT16_FORMAT "hu"</pre><p>This is the platform dependent conversion specifier for scanning andprinting values of type <a class="link" href="glib-Basic-Types.html#guint16"><span class="type">guint16</span></a>. See also <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS"><span class="type">G_GINT16_FORMAT</span></a>.</p></div><hr><div class="refsect2" lang="en"><a name="id2847194"></a><h3><a name="G-GINT32-MODIFIER:CAPS"></a>G_GINT32_MODIFIER</h3><a class="indexterm" name="id2847210"></a><pre class="programlisting">#define G_GINT32_MODIFIER ""</pre><p>The platform dependent length modifier for constructing <code class="function">printf()</code> conversionspecifiers for values of type <a class="link" href="glib-Basic-Types.html#gint32"><span class="type">gint32</span></a> or <a class="link" href="glib-Basic-Types.html#guint32"><span class="type">guint32</span></a>. See also <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-MODIFIER:CAPS"><span class="type">G_GINT16_MODIFIER</span></a>.</p><p class="since">Since 2.4</p></div><hr><div class="refsect2" lang="en"><a name="id2847268"></a><h3><a name="G-GINT32-FORMAT:CAPS"></a>G_GINT32_FORMAT</h3><a class="indexterm" name="id2847281"></a><pre class="programlisting">#define G_GINT32_FORMAT "i"</pre><p>This is the platform dependent conversion specifier for scanning andprinting values of type <a class="link" href="glib-Basic-Types.html#gint32"><span class="type">gint32</span></a>. See also <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS"><span class="type">G_GINT16_FORMAT</span></a>.</p></div><hr><div class="refsect2" lang="en"><a name="id2847314"></a><h3><a name="G-GUINT32-FORMAT:CAPS"></a>G_GUINT32_FORMAT</h3><a class="indexterm" name="id2847327"></a><pre class="programlisting">#define G_GUINT32_FORMAT "u"</pre><p>This is the platform dependent conversion specifier for scanning andprinting values of type <a class="link" href="glib-Basic-Types.html#guint32"><span class="type">guint32</span></a>. See also <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS"><span class="type">G_GINT16_FORMAT</span></a>.</p></div><hr><div class="refsect2" lang="en"><a name="id2847361"></a><h3><a name="G-GINT64-MODIFIER:CAPS"></a>G_GINT64_MODIFIER</h3><a class="indexterm" name="id2847376"></a><pre class="programlisting">#define G_GINT64_MODIFIER "ll"</pre><p>The platform dependent length modifier for constructing <code class="function">printf()</code> conversionspecifiers for values of type <a class="link" href="glib-Basic-Types.html#gint64"><span class="type">gint64</span></a> or <a class="link" href="glib-Basic-Types.html#guint64"><span class="type">guint64</span></a>. See also <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-MODIFIER:CAPS"><span class="type">G_GINT16_MODIFIER</span></a>.</p><div class="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"><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" lang="en"><a name="id2847452"></a><h3><a name="G-GINT64-FORMAT:CAPS"></a>G_GINT64_FORMAT</h3><a class="indexterm" name="id2847465"></a><pre class="programlisting">#define G_GINT64_FORMAT "lli"</pre><p>This is the platform dependent conversion specifier for scanning andprinting values of type <a class="link" href="glib-Basic-Types.html#gint64"><span class="type">gint64</span></a>. See also <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS"><span class="type">G_GINT16_FORMAT</span></a>.</p><div class="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"><span class="type">G_GINT64_FORMAT</span></a>is not defined. Note that <code class="function">scanf()</code> may not support 64 bit integers, evenif <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT64-FORMAT:CAPS"><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" lang="en"><a name="id2847559"></a><h3><a name="G-GUINT64-FORMAT:CAPS"></a>G_GUINT64_FORMAT</h3><a class="indexterm" name="id2847572"></a><pre class="programlisting">#define G_GUINT64_FORMAT "llu"</pre><p>This is the platform dependent conversion specifier for scanning andprinting values of type <a class="link" href="glib-Basic-Types.html#guint64"><span class="type">guint64</span></a>. See also <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS"><span class="type">G_GINT16_FORMAT</span></a>.</p><div class="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"><span class="type">G_GUINT64_FORMAT</span></a>is not defined. Note that <code class="function">scanf()</code> may not support 64 bit integers, evenif <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT64-FORMAT:CAPS"><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" lang="en"><a name="id2847665"></a><h3><a name="G-GSIZE-MODIFIER:CAPS"></a>G_GSIZE_MODIFIER</h3><a class="indexterm" name="id2847680"></a><pre class="programlisting">#define G_GSIZE_MODIFIER ""</pre><p>The platform dependent length modifier for constructing <code class="function">printf()</code> conversionspecifiers for values of type <a class="link" href="glib-Basic-Types.html#gsize"><span class="type">gsize</span></a> or <a class="link" href="glib-Basic-Types.html#gssize"><span class="type">gssize</span></a>. See also <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-MODIFIER:CAPS"><span class="type">G_GINT16_MODIFIER</span></a>.</p><p class="since">Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id2847738"></a><h3><a name="G-GSIZE-FORMAT:CAPS"></a>G_GSIZE_FORMAT</h3><a class="indexterm" name="id2847753"></a><pre class="programlisting">#define G_GSIZE_FORMAT "u"</pre><p>This is the platform dependent conversion specifier for scanning andprinting values of type <a class="link" href="glib-Basic-Types.html#gsize"><span class="type">gsize</span></a>. See also <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS"><span class="type">G_GINT16_FORMAT</span></a>.</p><p class="since">Since 2.6</p></div><hr><div class="refsect2" lang="en"><a name="id2847793"></a><h3><a name="G-GSSIZE-FORMAT:CAPS"></a>G_GSSIZE_FORMAT</h3><a class="indexterm" name="id2847809"></a><pre class="programlisting">#define G_GSSIZE_FORMAT "i"</pre><p>This is the platform dependent conversion specifier for scanning andprinting values of type <a class="link" href="glib-Basic-Types.html#gssize"><span class="type">gssize</span></a>. See also <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS"><span class="type">G_GINT16_FORMAT</span></a>.</p><p class="since">Since 2.6</p></div></div><div class="refsect1" lang="en"><a name="id2847850"></a><div class="refsect2" lang="en"><a name="id2847851"></a></div><hr><div class="refsect2" lang="en"><a name="id2847852"></a></div></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -