⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 glib-standard-macros.html

📁 glid编写实例
💻 HTML
📖 第 1 页 / 共 2 页
字号:
</tr><tr><td><span class="term"><em class="parameter"><code>b</code></em>&#160;:</span></td><td>a numeric value.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td><td>the maximum of <em class="parameter"><code>a</code></em> and <em class="parameter"><code>b</code></em>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2824958"></a><h3><a name="ABS:CAPS"></a>ABS()</h3><a class="indexterm" name="id2824968"></a><pre class="programlisting">#define ABS(a)	   (((a) &lt; 0) ? -(a) : (a))</pre><p>Calculates the absolute value of <em class="parameter"><code>a</code></em>.The absolute value is simply the number with any negative sign taken away.</p><p>For example,</p><div class="itemizedlist"><ul type="disc"><li><p>ABS(-10) is 10.</p></li><li><p>ABS(10) is also 10.</p></li></ul></div><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>a</code></em>&#160;:</span></td><td>a numeric value.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td><td>the absolute value of <em class="parameter"><code>a</code></em>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2825040"></a><h3><a name="CLAMP:CAPS"></a>CLAMP()</h3><a class="indexterm" name="id2825050"></a><pre class="programlisting">#define CLAMP(x, low, high)  (((x) &gt; (high)) ? (high) : (((x) &lt; (low)) ? (low) : (x)))</pre><p>Ensures that <em class="parameter"><code>x</code></em> is between the limits set by <em class="parameter"><code>low</code></em> and <em class="parameter"><code>high</code></em>.</p><p>For example,</p><div class="itemizedlist"><ul type="disc"><li><p>CLAMP(5, 10, 15) is 10.</p></li><li><p>CLAMP(15, 5, 10) is 10.</p></li><li><p>CLAMP(20, 15, 25) is 20.</p></li></ul></div><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>x</code></em>&#160;:</span></td><td>the value to clamp.</td></tr><tr><td><span class="term"><em class="parameter"><code>low</code></em>&#160;:</span></td><td>the minimum value allowed.</td></tr><tr><td><span class="term"><em class="parameter"><code>high</code></em>&#160;:</span></td><td>the maximum value allowed.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td><td>the value of <em class="parameter"><code>x</code></em> clamped to the range between <em class="parameter"><code>low</code></em> and <em class="parameter"><code>high</code></em>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2825182"></a><h3><a name="G-STRUCT-MEMBER:CAPS"></a>G_STRUCT_MEMBER()</h3><a class="indexterm" name="id2825192"></a><pre class="programlisting">#define     G_STRUCT_MEMBER(member_type, struct_p, struct_offset)</pre><p>Returns a member of a structure at a given offset, using the given type.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>member_type</code></em>&#160;:</span></td><td>the type of the struct field.</td></tr><tr><td><span class="term"><em class="parameter"><code>struct_p</code></em>&#160;:</span></td><td>a pointer to a struct.</td></tr><tr><td><span class="term"><em class="parameter"><code>struct_offset</code></em>&#160;:</span></td><td>the offset of the field from the start of the struct, in bytes.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td><td>the struct member.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2825267"></a><h3><a name="G-STRUCT-MEMBER-P:CAPS"></a>G_STRUCT_MEMBER_P()</h3><a class="indexterm" name="id2825278"></a><pre class="programlisting">#define     G_STRUCT_MEMBER_P(struct_p, struct_offset)</pre><p>Returns an untyped pointer to a given offset of a struct.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>struct_p</code></em>&#160;:</span></td><td>a pointer to a struct.</td></tr><tr><td><span class="term"><em class="parameter"><code>struct_offset</code></em>&#160;:</span></td><td>the offset from the start of the struct, in bytes.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td><td>an untyped pointer to <em class="parameter"><code>struct_p</code></em> plus <em class="parameter"><code>struct_offset</code></em> bytes.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2825350"></a><h3><a name="G-STRUCT-OFFSET:CAPS"></a>G_STRUCT_OFFSET()</h3><a class="indexterm" name="id2825361"></a><pre class="programlisting">#define     G_STRUCT_OFFSET(struct_type, member)</pre><p>Returns the offset, in bytes, of a member of a struct.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term"><em class="parameter"><code>struct_type</code></em>&#160;:</span></td><td>a structure type, e.g. <span class="structname">GtkWidget</span>.</td></tr><tr><td><span class="term"><em class="parameter"><code>member</code></em>&#160;:</span></td><td>a field in the structure, e.g. <em class="structfield"><code>window</code></em>.</td></tr><tr><td><span class="term"><span class="emphasis"><em>Returns</em></span>&#160;:</span></td><td>the offset of <em class="parameter"><code>member</code></em> from the start of <em class="parameter"><code>struct_type</code></em>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2825439"></a><h3><a name="G-MEM-ALIGN:CAPS"></a>G_MEM_ALIGN</h3><a class="indexterm" name="id2825450"></a><pre class="programlisting">#define     G_MEM_ALIGN</pre><p>Indicates the number of bytes to which memory will be aligned on thecurrent platform.</p></div><hr><div class="refsect2" lang="en"><a name="id2825466"></a><h3><a name="G-CONST-RETURN:CAPS"></a>G_CONST_RETURN</h3><a class="indexterm" name="id2825476"></a><pre class="programlisting">#define     G_CONST_RETURN</pre><p>If <code class="literal">G_DISABLE_CONST_RETURNS</code> is defined, this macro expands to nothing.By default, the macro expands to <code class="literal">const</code>. The macro should be used in place of <code class="literal">const</code> for functions that return a value that should not be modified. The purpose of this macro is to allow us to turn on <code class="literal">const</code> for returned constant strings by default, while allowing programmers who find that annoying to turn it off. This macro should only be used for return values and for<span class="emphasis"><em>out</em></span> parameters, it doesn't make sense for <span class="emphasis"><em>in</em></span> parameters. </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-Limits-of-Basic-Types.html"><b>&lt;&lt;&#160;Limits of Basic Types</b></a></td><td align="right"><a accesskey="n" href="glib-Type-Conversion-Macros.html"><b>Type Conversion Macros&#160;&gt;&gt;</b></a></td></tr></table></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -