Re: [Vala] compiler warning for Variant.strv()



    > On Thursday, 25 January 2018, 10:32:07 GMT, Yasushi SHOJI <yasushi shoji gmail com> wrote:  
void main () {
        Variant ary = new Variant.strv({"foo", "bar", "baz"});
}


/usr/include/glib-2.0/glib/gvariant.h:118:33: note: expected ‘const
gchar * const* {aka const char * const*}’ but argument is of type
‘gchar ** {aka char **}’
GVariant *                      g_variant_new_strv
  (const gchar * const  *strv,
                                ^~~~~~~~~~~~~~~~~~

Vala does have implicit conversion for Variant types, e.g.:
Variant a = "a string";Variant b = 10;
I've not figure out how well this works with collections, but there is this 
patch:https://mail.gnome.org/archives/commits-list/2010-October/msg08428.html

I've tried: Variant test = {"foo", "bar", "bax"};but get "error: initializer list used for `GLib.Variant?', 
which is neither array nor struct"
I also tried explicit casting:string[] test = {"foo", "bar", "baz"};
Variant result = (Variant) test;
This compiles without C warnings, but I get a runtime critical from GLib:GLib-CRITICAL **: g_variant_ref: 
assertion 'value->ref_count > 0' failed
So it looks like some development is needed in that area, if someone wants to take up the challenge!
Al






  


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]