例如:輸入以下的程式碼儲存成 hello.gs
init
print "Hello World"
然後再執行以下的指令就可以看到結果了。$ valac hello.gs $ ./hello如果說要看到中間轉譯出來的 C 語言程式碼可以輸入以下指令:
$ valac -C hello.gs於是就可以看到 hello.c 產生出來了。
/* hello.c generated by valac 0.14.0, the Vala compiler
* generated from hello.gs, do not modify */
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
void _vala_main (gchar** args, int args_length1);
void _vala_main (gchar** args, int args_length1) {
g_print ("Hello World\n");
}
int main (int argc, char ** argv) {
g_type_init ();
_vala_main (argv, argc);
return 0;
}
看看裡面的內容是不是一般所熟悉的 C 語言程式碼。:)參考資料:Genie - GNOME Live!
沒有留言:
張貼留言