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

📄 glib-miscellaneous-macros.html

📁 glid编写实例
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<html xmlns:cf="http://docbook.sourceforge.net/xmlns/chunkfast/1.0"><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"><title>Miscellaneous Macros</title><meta name="generator" content="DocBook XSL Stylesheets V1.69.0"><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.4 (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"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="glib-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></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><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 href="glib-Miscellaneous-Macros.html#G-INLINE-FUNC:CAPS">G_INLINE_FUNC</a>#define     <a href="glib-Miscellaneous-Macros.html#G-STMT-START:CAPS">G_STMT_START</a>#define     <a href="glib-Miscellaneous-Macros.html#G-STMT-END:CAPS">G_STMT_END</a>#define     <a href="glib-Miscellaneous-Macros.html#G-BEGIN-DECLS:CAPS">G_BEGIN_DECLS</a>#define     <a href="glib-Miscellaneous-Macros.html#G-END-DECLS:CAPS">G_END_DECLS</a>#define     <a href="glib-Miscellaneous-Macros.html#G-N-ELEMENTS:CAPS">G_N_ELEMENTS</a>                    (arr)#define     <a href="glib-Miscellaneous-Macros.html#G-VA-COPY:CAPS">G_VA_COPY</a>#define     <a href="glib-Miscellaneous-Macros.html#G-STRINGIFY:CAPS">G_STRINGIFY</a>                     (macro_or_string)#define     <a href="glib-Miscellaneous-Macros.html#G-GNUC-EXTENSION:CAPS">G_GNUC_EXTENSION</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GNUC-CONST:CAPS">G_GNUC_CONST</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GNUC-PURE:CAPS">G_GNUC_PURE</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GNUC-MALLOC:CAPS">G_GNUC_MALLOC</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GNUC-DEPRECATED:CAPS">G_GNUC_DEPRECATED</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GNUC-NORETURN:CAPS">G_GNUC_NORETURN</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GNUC-UNUSED:CAPS">G_GNUC_UNUSED</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GNUC-PRINTF:CAPS">G_GNUC_PRINTF</a>                   ( format_idx, arg_idx )#define     <a href="glib-Miscellaneous-Macros.html#G-GNUC-SCANF:CAPS">G_GNUC_SCANF</a>                    ( format_idx, arg_idx )#define     <a href="glib-Miscellaneous-Macros.html#G-GNUC-FORMAT:CAPS">G_GNUC_FORMAT</a>                   ( arg_idx )#define     <a href="glib-Miscellaneous-Macros.html#G-GNUC-FUNCTION:CAPS">G_GNUC_FUNCTION</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GNUC-PRETTY-FUNCTION:CAPS">G_GNUC_PRETTY_FUNCTION</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GNUC-NO-INSTRUMENT:CAPS">G_GNUC_NO_INSTRUMENT</a>#define     <a href="glib-Miscellaneous-Macros.html#G-HAVE-GNUC-VISIBILITY:CAPS">G_HAVE_GNUC_VISIBILITY</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GNUC-INTERNAL:CAPS">G_GNUC_INTERNAL</a>#define     <a href="glib-Miscellaneous-Macros.html#G-LIKELY:CAPS">G_LIKELY</a>                        (expr)#define     <a href="glib-Miscellaneous-Macros.html#G-UNLIKELY:CAPS">G_UNLIKELY</a>                      (expr)#define     <a href="glib-Miscellaneous-Macros.html#G-STRLOC:CAPS">G_STRLOC</a>#define     <a href="glib-Miscellaneous-Macros.html#G-STRFUNC:CAPS">G_STRFUNC</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GINT16-MODIFIER:CAPS">G_GINT16_MODIFIER</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GINT16-FORMAT:CAPS">G_GINT16_FORMAT</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GUINT16-FORMAT:CAPS">G_GUINT16_FORMAT</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GINT32-MODIFIER:CAPS">G_GINT32_MODIFIER</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GINT32-FORMAT:CAPS">G_GINT32_FORMAT</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GUINT32-FORMAT:CAPS">G_GUINT32_FORMAT</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GINT64-MODIFIER:CAPS">G_GINT64_MODIFIER</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GINT64-FORMAT:CAPS">G_GINT64_FORMAT</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GUINT64-FORMAT:CAPS">G_GUINT64_FORMAT</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GSIZE-MODIFIER:CAPS">G_GSIZE_MODIFIER</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GSIZE-FORMAT:CAPS">G_GSIZE_FORMAT</a>#define     <a href="glib-Miscellaneous-Macros.html#G-GSSIZE-FORMAT:CAPS">G_GSSIZE_FORMAT</a></pre></div><div class="refsect1" lang="en"><a name="id2838659"></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="id2838671"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id2838677"></a><h3><a name="G-INLINE-FUNC:CAPS"></a>G_INLINE_FUNC</h3><a class="indexterm" name="id2838686"></a><pre class="programlisting">#define     G_INLINE_FUNC</pre><p>Used to declare inline functions. If inline functions are not supported onthe particular platform, the macro evaluates to the empty string.</p></div><hr><div class="refsect2" lang="en"><a name="id2838704"></a><h3><a name="G-STMT-START:CAPS"></a>G_STMT_START</h3><a class="indexterm" name="id2838714"></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="id2838732"></a><h3><a name="G-STMT-END:CAPS"></a>G_STMT_END</h3><a class="indexterm" name="id2838742"></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="id2838759"></a><h3><a name="G-BEGIN-DECLS:CAPS"></a>G_BEGIN_DECLS</h3><a class="indexterm" name="id2838770"></a><pre class="programlisting">#define     G_BEGIN_DECLS</pre><p>Used (along with <a 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="id2838801"></a><h3><a name="G-END-DECLS:CAPS"></a>G_END_DECLS</h3><a class="indexterm" name="id2838811"></a><pre class="programlisting">#define     G_END_DECLS</pre><p>Used (along with <a 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="id2838842"></a><h3><a name="G-N-ELEMENTS:CAPS"></a>G_N_ELEMENTS()</h3><a class="indexterm" name="id2838853"></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><span class="term"><em class="parameter"><code>arr</code></em>&#160;:</span></td><td>the array</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2838890"></a><h3><a name="G-VA-COPY:CAPS"></a>G_VA_COPY</h3><a class="indexterm" name="id2838901"></a><pre class="programlisting">#define     G_VA_COPY</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><hr><div class="refsect2" lang="en"><a name="id2838951"></a><h3><a name="G-STRINGIFY:CAPS"></a>G_STRINGIFY()</h3><a class="indexterm" name="id2838962"></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><span class="term"><em class="parameter"><code>macro_or_string</code></em>&#160;:</span></td><td>a macro or a string.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id2838997"></a><h3><a name="G-GNUC-EXTENSION:CAPS"></a>G_GNUC_EXTENSION</h3><a class="indexterm" name="id2839009"></a><pre class="programlisting">#define     G_GNUC_EXTENSION</pre><p>Expands to <code class="literal">__extension__</code> when <span><strong class="command">gcc</strong></span> is used as the compiler.This simply tells <span><strong class="command">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="id2839047"></a><h3><a name="G-GNUC-CONST:CAPS"></a>G_GNUC_CONST</h3><a class="indexterm" name="id2839057"></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><strong class="command">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="id2839101"></a><h3><a name="G-GNUC-PURE:CAPS"></a>G_GNUC_PURE</h3><a class="indexterm" name="id2839111"></a><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><strong class="command">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>

⌨️ 快捷键说明

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