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

📄 glib-miscellaneous-macros.html

📁 最新gtk中文资料集
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"><title>Miscellaneous Macros</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><link rel="start" 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.9 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"><link rel="chapter" href="glib.html" title="GLib Overview"><link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals"><link rel="chapter" href="glib-core.html" title="GLib Core Application Support"><link rel="chapter" href="glib-utilities.html" title="GLib Utilities"><link rel="chapter" href="glib-data-types.html" title="GLib Data Types"><link rel="chapter" href="tools.html" title="GLib Tools"><link rel="index" href="ix01.html" title="Index"><link rel="index" href="ix02.html" title="Index of deprecated symbols"><link rel="index" href="ix03.html" title="Index of new symbols in 2.2"><link rel="index" href="ix04.html" title="Index of new symbols in 2.4"><link rel="index" href="ix05.html" title="Index of new symbols in 2.6"><link rel="index" href="ix06.html" title="Index of new symbols in 2.8"><link rel="index" href="ix07.html" title="Index of new symbols in 2.10"><link rel="index" href="ix08.html" title="Index of new symbols in 2.12"><link rel="index" href="ix09.html" title="Index of new symbols in 2.14"><link rel="index" href="ix10.html" title="Index of new symbols in 2.16"></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"><nobr><a href="#id2844810" class="shortcut">Top</a>                  &#160;|&#160;                  <a href="#id2845205" class="shortcut">Description</a></nobr></td></tr></table><div class="refentry" lang="en"><a name="glib-Miscellaneous-Macros"></a><div class="titlepage"></div><div class="refnamediv"><table width="100%"><tr><td valign="top"><h2><a name="id2844810"></a><span class="refentrytitle">Miscellaneous Macros</span></h2><p>Miscellaneous Macros &#8212; specialized macros which are not used often</p></td><td valign="top" align="right"></td></tr></table></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">#include &lt;glib.h&gt;#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-INLINE-FUNC:CAPS">G_INLINE_FUNC</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-STMT-START:CAPS">G_STMT_START</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-STMT-END:CAPS">G_STMT_END</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-BEGIN-DECLS:CAPS">G_BEGIN_DECLS</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-END-DECLS:CAPS">G_END_DECLS</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-N-ELEMENTS:CAPS">G_N_ELEMENTS</a>                        (arr)#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-VA-COPY:CAPS">G_VA_COPY</a>                           (ap1,ap2)#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-STRINGIFY:CAPS">G_STRINGIFY</a>                         (macro_or_string)#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-EXTENSION:CAPS">G_GNUC_EXTENSION</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-CONST:CAPS">G_GNUC_CONST</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-PURE:CAPS">G_GNUC_PURE</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-MALLOC:CAPS">G_GNUC_MALLOC</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-DEPRECATED:CAPS">G_GNUC_DEPRECATED</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-NORETURN:CAPS">G_GNUC_NORETURN</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-UNUSED:CAPS">G_GNUC_UNUSED</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-PRINTF:CAPS">G_GNUC_PRINTF</a>                       ( format_idx, arg_idx )#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-SCANF:CAPS">G_GNUC_SCANF</a>                        ( format_idx, arg_idx )#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-FORMAT:CAPS">G_GNUC_FORMAT</a>                       ( arg_idx )#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-NULL-TERMINATED:CAPS">G_GNUC_NULL_TERMINATED</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-WARN-UNUSED-RESULT:CAPS">G_GNUC_WARN_UNUSED_RESULT</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-FUNCTION:CAPS">G_GNUC_FUNCTION</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-PRETTY-FUNCTION:CAPS">G_GNUC_PRETTY_FUNCTION</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-NO-INSTRUMENT:CAPS">G_GNUC_NO_INSTRUMENT</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-HAVE-GNUC-VISIBILITY:CAPS">G_HAVE_GNUC_VISIBILITY</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-INTERNAL:CAPS">G_GNUC_INTERNAL</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GNUC-MAY-ALIAS:CAPS">G_GNUC_MAY_ALIAS</a>if                  <a class="link" href="glib-Miscellaneous-Macros.html#G-LIKELY:CAPS">G_LIKELY</a>                            ();#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-UNLIKELY:CAPS">G_UNLIKELY</a>                          (expr)#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-STRLOC:CAPS">G_STRLOC</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-STRFUNC:CAPS">G_STRFUNC</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-MODIFIER:CAPS">G_GINT16_MODIFIER</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS">G_GINT16_FORMAT</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GUINT16-FORMAT:CAPS">G_GUINT16_FORMAT</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT32-MODIFIER:CAPS">G_GINT32_MODIFIER</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT32-FORMAT:CAPS">G_GINT32_FORMAT</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GUINT32-FORMAT:CAPS">G_GUINT32_FORMAT</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT64-MODIFIER:CAPS">G_GINT64_MODIFIER</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GINT64-FORMAT:CAPS">G_GINT64_FORMAT</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GUINT64-FORMAT:CAPS">G_GUINT64_FORMAT</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GSIZE-MODIFIER:CAPS">G_GSIZE_MODIFIER</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GSIZE-FORMAT:CAPS">G_GSIZE_FORMAT</a>#define             <a class="link" href="glib-Miscellaneous-Macros.html#G-GSSIZE-FORMAT:CAPS">G_GSSIZE_FORMAT</a></pre></div><div class="refsect1" lang="en"><a name="id2845205"></a><h2>Description</h2><p>These macros provide more specialized features which are not needed so oftenby application programmers.</p></div><div class="refsect1" lang="en"><a name="id2845222"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id2845232"></a><h3><a name="G-INLINE-FUNC:CAPS"></a>G_INLINE_FUNC</h3><a class="indexterm" name="id2845244"></a><pre class="programlisting">#define             G_INLINE_FUNC</pre><p>This macro is used to export function prototypes so they can be linkedwith an external version when no inlining is performed. The file whichimplements 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"><code class="literal">G_INLINE_FUNC</code></a> declarations.Since inlining is very compiler-dependent using these macros correctlyis 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 headersand can be used normally.</p></div><hr><div class="refsect2" lang="en"><a name="id2845294"></a><h3><a name="G-STMT-START:CAPS"></a>G_STMT_START</h3><a class="indexterm" name="id2845306"></a><pre class="programlisting">#define             G_STMT_START</pre><p>Used within multi-statement macros so that they can be used in places whereonly one statement is expected by the compiler.</p></div><hr><div class="refsect2" lang="en"><a name="id2845324"></a><h3><a name="G-STMT-END:CAPS"></a>G_STMT_END</h3><a class="indexterm" name="id2845337"></a><pre class="programlisting">#define             G_STMT_END</pre><p>Used within multi-statement macros so that they can be used in places whereonly one statement is expected by the compiler.</p></div><hr><div class="refsect2" lang="en"><a name="id2845354"></a><h3><a name="G-BEGIN-DECLS:CAPS"></a>G_BEGIN_DECLS</h3><a class="indexterm" name="id2845367"></a><pre class="programlisting">#define             G_BEGIN_DECLS</pre><p>Used (along with <a class="link" href="glib-Miscellaneous-Macros.html#G-END-DECLS:CAPS"><span class="type">G_END_DECLS</span></a>) to bracket header files. If thecompiler in use is a C++ compiler, adds <code class="literal">extern "C"</code> around the header.</p></div><hr><div class="refsect2" lang="en"><a name="id2845398"></a><h3><a name="G-END-DECLS:CAPS"></a>G_END_DECLS</h3><a class="indexterm" name="id2845411"></a><pre class="programlisting">#define             G_END_DECLS</pre><p>Used (along with <a class="link" href="glib-Miscellaneous-Macros.html#G-BEGIN-DECLS:CAPS"><span class="type">G_BEGIN_DECLS</span></a>) to bracket header files. If thecompiler in use is a C++ compiler, adds <code class="literal">extern "C"</code> around the header.</p></div><hr><div class="refsect2" lang="en"><a name="id2845442"></a><h3><a name="G-N-ELEMENTS:CAPS"></a>G_N_ELEMENTS()</h3><a class="indexterm" name="id2845454"></a><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 bedeclared so the compiler knows its size at compile-time; this macro will not work on an array allocated on the heap, only staticarrays 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>&#160;:</span></p></td><td>the array</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2845492"></a><h3><a name="G-VA-COPY:CAPS"></a>G_VA_COPY()</h3><a class="indexterm" name="id2845505"></a><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>&#160;:</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>&#160;:</span></p></td><td>a <span class="type">va_list</span>.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2845601"></a><h3><a name="G-STRINGIFY:CAPS"></a>G_STRINGIFY()</h3><a class="indexterm" name="id2845613"></a><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.</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>&#160;:</span></p></td><td>a macro or a string.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2845649"></a><h3><a name="G-GNUC-EXTENSION:CAPS"></a>G_GNUC_EXTENSION</h3><a class="indexterm" name="id2845663"></a><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 codewhen compiling with the <code class="option">-pedantic</code> option.</p></div><hr><div class="refsect2" lang="en"><a name="id2845702"></a><h3><a name="G-GNUC-CONST:CAPS"></a>G_GNUC_CONST</h3><a class="indexterm" name="id2845713"></a><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" 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" lang="en"><a name="id2845757"></a><h3><a name="G-GNUC-PURE:CAPS"></a>G_GNUC_PURE</h3><a class="indexterm" name="id2845770"></a><pre class="programlisting">#define             G_GNUC_PURE</pre>

⌨️ 快捷键说明

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