Add the G_OPTION_ENTRY_NULL macro to properly initialize GOptionEntry arrays

This commit is contained in:
Emmanuel Fleury 2021-05-13 00:51:08 +02:00
parent c0b339372c
commit 2e4524cd36
3 changed files with 20 additions and 1 deletions

View File

@ -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

View File

@ -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

View File

@ -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