value in values: Params of the search function should be const
@aplazas
Submitted by Adrien Plazas Link to original bug (#752288)
Description
To compile this vala code:
if (value in values)
where value is a string and values a string[], valac generated a function whose prototype is:
static gboolean _vala_string_array_contains (gchar** stack, int stack_length, gchar* needle);
but the values it passes to the needle params is contant, and hence I got this error:
variable/Options.c: In function 'retro_option_set_current':
variable/Options.c:272:59: warning: passing argument 3 of '_vala_string_array_contains' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
if (_vala_string_array_contains (_tmp1_, _tmp1__length1, _tmp0_)) {
^
variable/Options.c:253:17: note: expected 'gchar * {aka char *}' but argument is of type 'const gchar * {aka const char *}'
static gboolean _vala_string_array_contains (gchar** stack, int stack_length, gchar* needle) {
^
I would suggest to make the stack and needle parameters constant as they are never changed by the function.