[glib: 1/12] Add the G_OPTION_ENTRY_NULL macro to properly initialize GOptionEntry arrays
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 1/12] Add the G_OPTION_ENTRY_NULL macro to properly initialize GOptionEntry arrays
- Date: Thu, 13 May 2021 12:04:46 +0000 (UTC)
commit 2e4524cd3664dc3d0c3b959d1cd1a854a84a4157
Author: Emmanuel Fleury <emmanuel fleury gmail com>
Date: Thu May 13 00:51:08 2021 +0200
Add the G_OPTION_ENTRY_NULL macro to properly initialize GOptionEntry arrays
docs/reference/glib/glib-sections.txt | 1 +
glib/goption.c | 2 +-
glib/goption.h | 18 ++++++++++++++++++
3 files changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/docs/reference/glib/glib-sections.txt b/docs/reference/glib/glib-sections.txt
index 46a88af0b..d8a8d7d95 100644
--- a/docs/reference/glib/glib-sections.txt
+++ b/docs/reference/glib/glib-sections.txt
@@ -1649,6 +1649,7 @@ GOptionArg
GOptionFlags
G_OPTION_REMAINING
GOptionEntry
+G_OPTION_ENTRY_NULL
g_option_context_add_main_entries
GOptionGroup
g_option_context_add_group
diff --git a/glib/goption.c b/glib/goption.c
index c974598c8..8cb72376c 100644
--- a/glib/goption.c
+++ b/glib/goption.c
@@ -102,7 +102,7 @@
* { "verbose", 'v', 0, G_OPTION_ARG_NONE, &verbose, "Be verbose", NULL },
* { "beep", 'b', 0, G_OPTION_ARG_NONE, &beep, "Beep when done", NULL },
* { "rand", 0, 0, G_OPTION_ARG_NONE, &randomize, "Randomize the data", NULL },
- * { NULL }
+ * G_OPTION_ENTRY_NULL
* };
*
* int
diff --git a/glib/goption.h b/glib/goption.h
index 63552fb0d..44815a77d 100644
--- a/glib/goption.h
+++ b/glib/goption.h
@@ -286,6 +286,24 @@ struct _GOptionEntry
*/
#define G_OPTION_REMAINING ""
+/**
+ * G_OPTION_ENTRY_NULL:
+ *
+ * A #GOptionEntry array requires a %NULL terminator, this macro can
+ * be used as terminator instead of an explicit `{ 0 }` but it cannot
+ * be assigned to a variable.
+ *
+ * |[
+ * GOptionEntry option[] = { G_OPTION_ENTRY_NULL };
+ * ]|
+ *
+ * Since: 2.70
+ */
+#define G_OPTION_ENTRY_NULL \
+ GLIB_AVAILABLE_MACRO_IN_2_70 \
+ { NULL, 0, 0, 0, NULL, NULL, NULL }
+
+
GLIB_AVAILABLE_IN_ALL
GOptionContext *g_option_context_new (const gchar *parameter_string);
GLIB_AVAILABLE_IN_ALL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]