According with the documentation the example code which uses c libraries inside V must work, but that not works, when i try to compile i get:
panic: sqlix.v:6
usestruct sqlite3 {instead oftype sqlite3 struct {
exit():
To understand how to deal with this, will be great working / updating examples
Yes, i have i try that but after that a next problem, that's why i post an issue (probably will be another and another):
#flag -lsqlite3
#include "sqlite3.h"
struct C.sqlite3 {}
struct C.sqlite3_stmt {}
fn C.sqlite3_column_int(C.sqlite_stmt, int) int {}
fn main() {
path := 'sqlite3_users.db'
db := &C.sqlite3{}
C.sqlite3_open(path.cstr(), &db)
query := 'select count(*) from users'
stmt := &C.sqlite3_stmt{}
C.sqlite3_prepare_v2(db, query.cstr(), - 1, &stmt, 0)
C.sqlite3_step(stmt)
nr_users := C.sqlite3_column_int(res, 0)
C.sqlite3_finalize(res)
println(nr_users)
}
Result now:
check()
next token =fn
pass=1 fn=`panic: sqlix.v:10 expectedNAMEbut got}`
I'm trying to implement a socket module and am running into a similar issue
module socket
#include <sys/socket.h>
pub fn socket(domain int, _type int, proto int) {
sockfd := C.socket(domain, _type, proto)
}
When I compile I get
check()
next token =domain
pass=2 fnsocket__socket
panic: socket.v:6
expected.but got(
If I compare p.tok and DOT here, before entering the check they'll match (as expected), but if I compare p.tok and DOT inside the check (right here) they differ
Hello,
I'm aware of this bug, it will be fixed asap.
In many cases, for now the following hack will work:
add an empty function fn foobar() {} after your C function definitions:
fn C.fn1()
fn C.fn2()
fn foobar() {}
...
I am closing this issue because it comes from v 0.1.7 and we are at 0.1.18 already. Many things have changed, especially concerning this topic. If these problems are still persistent, please open a new issue.
Most helpful comment
Hello,
I'm aware of this bug, it will be fixed asap.