dev/c/g_quark/gquark_test.c

54 lines
1.2 KiB
C

#include <glib.h>
#include <stdio.h>
int main(void)
{
GQuark q1,
q2,
q3,
q4,
q5,
q6,
q7,
q8;
static const gchar *str1 = "str1",
*str2 = "str2";
gchar str3[] = "str1",
str4[] = "str2";
q1 = g_quark_from_string (str1);
q2 = g_quark_from_string (str1);
q3 = g_quark_from_static_string (str1);
q4 = g_quark_from_static_string (str1);
q5 = g_quark_from_string (str2);
q6 = g_quark_from_string (str2);
q7 = g_quark_from_static_string (str2);
q8 = g_quark_from_static_string (str2);
printf ("q[1-4] = %d, %d, %d, %d\n", q1, q2, q3, q4);
printf ("q[5-8] = %d, %d, %d, %d\n", q5, q6, q7, q8);
printf ("g_quark_to_string ():\n%s, %s, %s, %s,\n%s, %s, %s, %s\n",
g_quark_to_string (q1),
g_quark_to_string (q2),
g_quark_to_string (q3),
g_quark_to_string (q4),
g_quark_to_string (q5),
g_quark_to_string (q6),
g_quark_to_string (q7),
g_quark_to_string (q8));
printf ("g_quark_try_string (): %d, %d, %d, %d\n",
g_quark_try_string (str1),
g_quark_try_string (str2),
g_quark_try_string (str3),
g_quark_try_string (str4));
return 0;
}