如何在vala中使用gettext?
当我尝试在 vala 中使用 gettext 时,我没有收到来自 vala 的错误或警告,但我从 c 编译器收到以下错误:
/usr/include/glib-2.0/glib/gi18n-lib.h:29:2: error: #error You must define GETTEXT_PACKAGE before including gi18n-lib.h. Did you forget to include config.h?
如何解决此问题?
When I try to use gettext in vala I get not errors or warnings from vala but I get the following error from the c compiler:
/usr/include/glib-2.0/glib/gi18n-lib.h:29:2: error: #error You must define GETTEXT_PACKAGE before including gi18n-lib.h. Did you forget to include config.h?
How can I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为了解决这个问题,我必须将
-X -DGETTEXT_PACKAGE="..."
添加到 valac 命令,并将const string GETTEXT_PACKAGE = "...";
添加到我的源文件的顶部。如果我不将其添加到源文件的顶部,由于某种原因,我会从 C 编译器中收到大量
未声明(首次在此函数中使用)
错误。然而,我确实收到了 C 编译器关于重新定义 GETTEXT_PACKAGE 的警告。
To solve this problem I had to both add
-X -DGETTEXT_PACKAGE="..."
to the valac command and addconst string GETTEXT_PACKAGE = "...";
to the top of my source file.If I don't add that to the top of my source file, I get lots of
undeclared (first use in this function)
errors from the C compiler for some reason.I do, however, get a warning from the C compiler for redefining GETTEXT_PACKAGE.
我认为最常见的解决方案是将 -DGETTEXT_PACKAGE="..." 传递给 C 编译器(如果您只是依赖 valac 来调用它,请将 -X -DGETTEXT_PACKAGE="..." 传递给 valac)。
I think the most common solution is to just pass -DGETTEXT_PACKAGE="..." to the C compiler (if you're just relying on valac to invoke it, pass -X -DGETTEXT_PACKAGE="..." to valac).
这可以帮助:https://bugzilla.gnome.org/show_bug.cgi?id=618931
This can help: https://bugzilla.gnome.org/show_bug.cgi?id=618931