Re: [Vala] Using Vala under syscall


You can write vapi files with the structures, functions and constants of every header file.

Here is a little example:


[[CCode (lower_case_cprefix ="", cheader_filename="sys/io.h")
namespace Io
    public static int ioperm (ulong from, ulong num, bool turn_on);
    public static uchar inb (ushort port);

Then use the vapi file with this source:

using GLib;
using Io;

public class Sample : GLib.Object
    public static void main (string[] args)
        ioperm (0x0378, 0x0380, true);
        uchar a = inb (0x0379);
        print ("%d", a);

Compile the code with:
valac  sample.vala --pkg io  --vapidir .

I hope that this will be helpful

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