【问题标题】:Getting a bunch of GCC warnings收到一堆 GCC 警告
【发布时间】: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


【解决方案1】:

根据this answer,您没有做错任何事情,只是 C 编译器没有 vala 编译器那么多的信息,因此抱怨 valac 生成的一些 C 代码。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-30
    • 2011-09-16
    相关资源
    最近更新 更多