一个简单的程序,在编译时会发现一串C警告,以查找字符串中是否存在相同的字母。我究竟做错了什么? (程序正常运行)
using Gee;
void main(string[] args) {
var s="♜♝♞♟♠♞";
unichar c;
var records = new HashMap<unichar, bool> ();
for (int i = 0; s.get_next_char (ref i, out c);) {
stdout.printf (@"$i, $c\t");
if (records[c]==true){
stdout.printf("буква найдена: true\n");break;
}else{
records[c]=true;stdout.printf("буква не найдена: false\n");
}
}
}
gavr@archlabs ~/D/c/V/T / Task51> vala console.vala --pkg gee-0.8
/tmp / console.vala.BF33WZ.c: in the function " g_unichar_to_string»:
/tmp / console.vala.BF33WZ.c: 65: 27: warning: passing argument 2 " g_unichar_to_utf8 "cancels the" const " qualifier of the type [- Wdiscarded-qualifiers]
g_unichar_to_utf8 (self, _tmp1_);
^~~~~~
In file included from/usr/include/glib-2.0/glib / gstring.h: 33,
from / usr/include/glib-2.0/glib / giochannel.h: 34,
from / usr/include/glib-2.0 / glib.h: 54,
from / tmp / console.vala.BF33WZ.c: 6.:
/usr/include/glib-2.0/glib / gunicode.h:844:42: note: type "gchar *" {aka "char*"} was expected, but the argument is of type "const gchar *" {aka " const char *»}
gchar *outbuf);