From df6714102c3968bd2d5516bd8441435cee2fc689 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Sun, 22 Sep 2019 15:33:42 +0200 Subject: [PATCH] shared: add NM_G_VARIANT_TYPE() macro Like G_VARIANT_TYPE(), but this one can be used to initialize a static variable. --- shared/nm-glib-aux/nm-macros-internal.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/shared/nm-glib-aux/nm-macros-internal.h b/shared/nm-glib-aux/nm-macros-internal.h index 9292f3699d..09f96ef6ba 100644 --- a/shared/nm-glib-aux/nm-macros-internal.h +++ b/shared/nm-glib-aux/nm-macros-internal.h @@ -1262,6 +1262,14 @@ nm_clear_g_cancellable_disconnect (GCancellable *cancellable, gulong *cancellabl /*****************************************************************************/ +/* GVariantType is basically a C string. But G_VARIANT_TYPE() is not suitable + * to initialize a static variable (because it evaluates a function check that + * the string is valid). Add an alternative macro that does the plain cast. + * + * Here you loose the assertion check that G_VARIANT_TYPE() to ensure the + * string is valid. */ +#define NM_G_VARIANT_TYPE(fmt) ((const GVariantType *) (""fmt"")) + static inline GVariant * nm_g_variant_ref (GVariant *v) {