【发布时间】:2019-02-11 10:23:10
【问题描述】:
一个简单的程序来查找字符串中是否有相同的字母,编译时会产生一堆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);
【问题讨论】:
-
恕我直言,
vala往往已被弃用。这些只是 GCC 对vala生成的 C 代码给出的警告。您可以选择忽略这些警告(或者修补vala转译器以通过添加显式转换来改进 C 代码生成) -
我不这么认为,最后一次更新是2月2日。wiki.gnome.org/Projects/Vala
-
Vala 的弃用方式与 C 相同——不喜欢它的人不要使用它。
-
然后考虑向 Vala 报告一个错误,如果可能的话,提出一个修复该问题的补丁。
标签: vala