Re: [Vala] Accessing properties of a Map.Entry from a read-only Gee map causes compiler warning





From: Nicolas Laplante <nicolas laplante gmail com>

Sent: Thursday, 19 November 2015, 19:33
Subject: [Vala] Accessing properties of a Map.Entry from a read-only Gee map causes compiler warning

foreach (Map.Entry<GB.Model.Date, Gee.List<Transaction>> entry in
transactions_by_date.entries) {
    // ...
}

Within this loop, whenver I access entry.key or entry.value, I get the
following compiler warning:

src/ui/tree_store_transaction.vala:284:14: warning: assignment discards
‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
                         debug ("transaction group: %s (%d
transaction(s))", entry.key.to_string (), entry.value.size);

I get this warning for each line accessing properties of the "entry"
variable. Is this normal?


It is "normal" in the sense that I also get these warnings from the
C compiler and the generated binary still works fine.

Ideally the generated C code from the Vala compiler would produce
code that avoided these warnings, but that means digging deep.

If you are finding the C compiler warnings distracting from 

Vala compiler warnings then you can add the option:
-X -w 
to the valac command. This passes a message to the C compiler to 

not show the warnings.

See also:
http://stackoverflow.com/questions/19468179/understanding-vala-compilation-warnings

Al


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