Re: [Vala] Calling C code from Vala



On 08/09/2007, pancake <pancake youterm com> wrote:
$ cat foo.vala
using GLib;

public class Foo.Bar
{
        public static int main(string[] args)
        {
                hello_msg("World!");
                return 0;
        }

        [Import ()]
        public static void hello_msg(string name);
}

We define an imported static method (no need to be static, but for a simple example is ok)
on the Bar class of the Foo namespace.

Now we implement the hello_msg function in C inside bar.c:

$ cat bar.c
void foo_bar_hello_msg(void *name)
{
        printf("Name: %s\n", name);
}

That is. Quite easy :)

*Very* sweet!

-- 
Michel



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]