在vala中哪里可以找到Glib对象?
我刚刚开始学习vala。我尝试了 vala 教程 中的以下程序。
class Demo.Hello : Glib.Object
{
public static int main( string[] args )
{
stdout.printf("Hello, Vala!\n");
return 0;
}
}
当我编译时得到了这个。
$ valac hello.vala
hello.vala:1.20-1.23: error: The symbol `Glib' could not be found
class Demo.Hello : Glib.Object
^^^^
Compilation failed: 1 error(s), 0 warning(s)
[1]+ Done gvim hello.vala
如果我从 Glib.Object
中删除 Glib.
,即仅保留 class Demo.Hello : Object
,那么一切都会正常。但本教程中的所有程序都使用 Glib.Object。这是怎么回事?我寻找答案但找不到。这是 vala 版本信息:
$ valac --version
Vala 0.5.2
我正在运行最新版本的 CentOS。
I just started with learning vala. I tried the following program from the vala tutorial.
class Demo.Hello : Glib.Object
{
public static int main( string[] args )
{
stdout.printf("Hello, Vala!\n");
return 0;
}
}
and got this when I compiled.
$ valac hello.vala
hello.vala:1.20-1.23: error: The symbol `Glib' could not be found
class Demo.Hello : Glib.Object
^^^^
Compilation failed: 1 error(s), 0 warning(s)
[1]+ Done gvim hello.vala
If I remove Glib.
from Glib.Object
i.e leave it with just class Demo.Hello : Object
, then everything works fine. But all the programs in the tutorial use Glib.Object
. What's wrong here? I searched for answers but could not find it. Here is the vala version info:
$ valac --version
Vala 0.5.2
And I am running the latest version of CentOS.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
命名空间称为 GLib(带有大 L)而不是 Glib..
The namespace is called GLib (with big L) not Glib..
正确的名称是 GLib。但你也可以离开“GLib”。只要写“Object”,GLib 命名空间就会在所有 vala 应用程序中隐式使用。
对于其他命名空间,您可以使用“using”,例如
using Gtk;
。The correct name is GLib. But you can just as well leave the "GLib." out and just write "Object", the GLib namespace is implicitely used in all vala apps.
For other namespaces you can use "using", for example
using Gtk;
.