2 Hello world
What can be first program we will write? There is only one choice... :) So startup your favorite editor and create file named hello.g
with the following contents:
section init
{
print_string("Hello world!\n");
}
Gont requires each module to have an interface. For example:
[malekith@roke gont-tut]$ ls
hello.g
[malekith@roke gont-tut]$ gontc hello.g
hello.g:0:1: cannot find module interface for Hello: file not found
[malekith@roke gont-tut]$
Interface should be in file under the same name as implementation file,
but with .gi suffix. We will talk about modules more in Section
17 below. For now, we don't need anything special in interface,
so we create it empty:
[malekith@roke gont-tut]$ echo > hello.gi
[malekith@roke gont-tut]$ gontc -c hello.gi
[malekith@roke gont-tut]$ gontc hello.g
[malekith@roke gont-tut]$ ./a.out
Hello world!
[malekith@roke gont-tut]$
It works! :)