Vala: extern_c.

This commit is contained in:
Kolan Sh 2013-02-08 00:13:21 +04:00
parent 1e6235a449
commit ff421afbd6
3 changed files with 20 additions and 0 deletions

7
vala/extern_c/c_code.c Normal file
View File

@ -0,0 +1,7 @@
#include <glib.h>
void c_func (gchar *str,
GHashTable *htable)
{
g_printf ("Do something with str and htable...");
}

5
vala/extern_c/test.sh Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
cc -c `pkg-config --cflags glib-2.0` c_code.c -o c_code.o
valac -c vala_code.vala
cc *.o -o app `pkg-config --libs glib-2.0 gobject-2.0`

View File

@ -0,0 +1,8 @@
extern void c_func (string? str, HashTable<string, string> hash_func);
void main () {
stdout.printf ("Hello world!\n");
var hash_func = new HashTable<string, string> (str_hash, str_equal);
c_func ("abc", hash_func);
}