Hi,
I'm reviving hare-sqlite
https://git.sr.ht/~blainsmith/hare-sqlite
I get errors from the yesterday Hare build, how do I correctly convert
this struct
export type handle = struct {
sqlite: *void,
};
That is used as follows
let h = alloc(handle { ... });
wrapvoid(_open(_filename, &h.sqlite))?;
Currently the errors is
Field 'sqlite' is uninitialized
18 | let h = alloc(handle { ... });
Regards,
Dmitry.
hey,
pointers don't have a default value to be used by `...`,
so you'd need to get the db handle before allocating the struct:
let db: nullable *void = null;
wrapvoid(_open(_filename, &db))?;
let h = alloc(handle {
sqlite = db as *void,
});
though i'm not sure why `handle` isn't simply `*void` directly,
maybe the struct was meant to be extended in the future but otherwise
it should probably just be dropped? i.e.
let db: nullable *void = null;
wrapvoid(_open(_filename, &db))?;
return db as *void;
"Jonas Fentker" <jonas@fentker.eu> writes:
> let db: nullable *void = null;> wrapvoid(_open(_filename, &db))?;> return db as *void;
That works, thanks!
I guess the struct was there to make it a "distinct" type so that you
can't pass another *void to the same parameter.