📄 macros_misc.sgml
字号:
<refsect2><title><anchor id="G-GNUC-PRINTF-CAPS">G_GNUC_PRINTF()</title><programlisting>#define G_GNUC_PRINTF( format_idx, arg_idx )</programlisting><para>Expands to the GNU C <literal>format</literal> function attribute if the compiler is <command>gcc</command>.This is used for declaring functions which take a variable number ofarguments, with the same syntax as <function>printf()</function>.It allows the compiler to type-check the arguments passed to the function.See the GNU C documentation for details. </para><informalexample><programlisting>gint g_snprintf (gchar *string, gulong n, gchar const *format, ...) G_GNUC_PRINTF (3, 4);</programlisting></informalexample><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>format_idx</parameter> :</entry><entry>the index of the argument corresponding to the format string.(The arguments are numbered from 1).</entry></row><row><entry align="right"><parameter>arg_idx</parameter> :</entry><entry>the index of the first of the format arguments.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="G-GNUC-SCANF-CAPS">G_GNUC_SCANF()</title><programlisting>#define G_GNUC_SCANF( format_idx, arg_idx )</programlisting><para>Expands to the GNU C <literal>format</literal> function attribute if the compiler is <command>gcc</command>.This is used for declaring functions which take a variable number ofarguments, with the same syntax as <function><link linkend="scanf">scanf</link>()</function>.It allows the compiler to type-check the arguments passed to the function.See the GNU C documentation for details. </para><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>format_idx</parameter> :</entry><entry>the index of the argument corresponding to the format string.(The arguments are numbered from 1).</entry></row><row><entry align="right"><parameter>arg_idx</parameter> :</entry><entry>the index of the first of the format arguments.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="G-GNUC-FORMAT-CAPS">G_GNUC_FORMAT()</title><programlisting>#define G_GNUC_FORMAT( arg_idx )</programlisting><para>Expands to the GNU C <literal>format_arg</literal> function attribute if the compiler is <command>gcc</command>.This function attribute specifies that a function takes a formatstring for a <function>printf()</function>, <function><link linkend="scanf">scanf</link>()</function>, <function><link linkend="strftime">strftime</link>()</function> or <function><link linkend="strfmon">strfmon</link>()</function> stylefunction and modifies it, so that the result can be passed to a <function>printf()</function>, <function><link linkend="scanf">scanf</link>()</function>, <function><link linkend="strftime">strftime</link>()</function> or <function><link linkend="strfmon">strfmon</link>()</function> 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. </para><informalexample><programlisting>gchar *g_dgettext (gchar *domain_name, gchar *msgid) G_GNUC_FORMAT (2);</programlisting></informalexample><informaltable pgwide="1" frame="none" role="params"><tgroup cols="2"><colspec colwidth="2*"><colspec colwidth="8*"><tbody><row><entry align="right"><parameter>arg_idx</parameter> :</entry><entry>the index of the argument.</entry></row></tbody></tgroup></informaltable></refsect2><refsect2><title><anchor id="G-GNUC-FUNCTION-CAPS">G_GNUC_FUNCTION</title><programlisting>#define G_GNUC_FUNCTION</programlisting><para>Expands to the GNU C <literal>__FUNCTION__</literal> variable if the compiler is <command>gcc</command>, or "" if it isn't. The GNU C <literal>__FUNCTION__</literal> variable contains the name of the current function. See the GNU C documentation for details. </para></refsect2><refsect2><title><anchor id="G-GNUC-PRETTY-FUNCTION-CAPS">G_GNUC_PRETTY_FUNCTION</title><programlisting>#define G_GNUC_PRETTY_FUNCTION</programlisting><para>Expands to the GNU C <literal>__PRETTY_FUNCTION__</literal> variable if the compiler is <command>gcc</command>, or "" if it isn't.The GNU C <literal>__PRETTY_FUNCTION__</literal> variable contains the name of the current function. For a C program this is the same as the <literal>__FUNCTION__</literal> variable but for C++ it also includes extra information such as the class and function prototype. See the GNU C documentation for details. </para></refsect2><refsect2><title><anchor id="G-GNUC-NO-INSTRUMENT-CAPS">G_GNUC_NO_INSTRUMENT</title><programlisting>#define G_GNUC_NO_INSTRUMENT</programlisting><para>Expands to the GNU C <literal>no_instrument_function</literal> function attribute if the compiler is <command>gcc</command>. Functions with this attribute will not be instrumented for profiling, when the compiler is called with the<option>-finstrument-functions</option> option.See the GNU C documentation for details. </para></refsect2><refsect2><title><anchor id="G-STRLOC-CAPS">G_STRLOC</title><programlisting>#define G_STRLOC</programlisting><para>Expands to a string identifying the current code position. </para></refsect2><refsect2><title><anchor id="G-GINT16-FORMAT-CAPS">G_GINT16_FORMAT</title><programlisting>#define G_GINT16_FORMAT "hi"</programlisting><para>This is the platform dependent conversion specifier for scanning andprinting values of type <link linkend="gint16">gint16</link>. 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.</para><para><informalexample><programlisting>gint16 in;gint32 out;sscanf ("42", "%" G_GINT16_FORMAT, &in)out = in * 1000;g_print ("%" G_GINT32_FORMAT, out);</programlisting></informalexample></para></refsect2><refsect2><title><anchor id="G-GUINT16-FORMAT-CAPS">G_GUINT16_FORMAT</title><programlisting>#define G_GUINT16_FORMAT "hu"</programlisting><para>This is the platform dependent conversion specifier for scanning andprinting values of type <link linkend="guint16">guint16</link>. See also <link linkend="G-GINT16-FORMAT-CAPS">G_GINT16_FORMAT</link>.</para></refsect2><refsect2><title><anchor id="G-GINT32-FORMAT-CAPS">G_GINT32_FORMAT</title><programlisting>#define G_GINT32_FORMAT "i"</programlisting><para>This is the platform dependent conversion specifier for scanning andprinting values of type <link linkend="gint32">gint32</link>. See also <link linkend="G-GINT16-FORMAT-CAPS">G_GINT16_FORMAT</link>.</para></refsect2><refsect2><title><anchor id="G-GUINT32-FORMAT-CAPS">G_GUINT32_FORMAT</title><programlisting>#define G_GUINT32_FORMAT "u"</programlisting><para>This is the platform dependent conversion specifier for scanning andprinting values of type <link linkend="guint32">guint32</link>. See also <link linkend="G-GINT16-FORMAT-CAPS">G_GINT16_FORMAT</link>.</para></refsect2><refsect2><title><anchor id="G-GINT64-FORMAT-CAPS">G_GINT64_FORMAT</title><programlisting>#define G_GINT64_FORMAT "lli"</programlisting><para>This is the platform dependent conversion specifier for scanning andprinting values of type <link linkend="gint64">gint64</link>. See also <link linkend="G-GINT16-FORMAT-CAPS">G_GINT16_FORMAT</link>.</para><note><para>Some platforms do not support scanning and printing 64 bit integers,even though the types are supported. On such platforms <link linkend="G-GINT64-FORMAT-CAPS">G_GINT64_FORMAT</link>is not defined.</para></note></refsect2><refsect2><title><anchor id="G-GUINT64-FORMAT-CAPS">G_GUINT64_FORMAT</title><programlisting>#define G_GUINT64_FORMAT "llu"</programlisting><para>This is the platform dependent conversion specifier for scanning andprinting values of type <link linkend="guint64">guint64</link>. See also <link linkend="G-GINT16-FORMAT-CAPS">G_GINT16_FORMAT</link>.</para><note><para>Some platforms do not support scanning and printing 64 bit integers,even though the types are supported. On such platforms <link linkend="G-GUINT64-FORMAT-CAPS">G_GUINT64_FORMAT</link>is not defined.</para></note></refsect2></refsect1></refentry>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -