c-for-go
c-for-go copied to clipboard
[question] generate Go function which accepts slice (without length) for C function that accepts dynamic array
Suppose a header file with the following:
typedef struct {
uint8_t x;
} Flarp;
uint64_t foo(const Flarp *input_ptr, size_t input_len);
With no TRANSLATOR PtrTips specified, c-for-go generates the following Go signature:
func Foo(inputPtr []Flarp, inputLen uint) uint64 {
My question: Does there exist a configuration setting (in YAML) which will produce the following Go signature?
func Foo(inputPtr []Flarp) uint64 {
I would expect that the size_t input_len argument would be computed at runtime in the (automatically-generated) body (or some helper) of the Foo function.
@laser did you ever find a solution to this?
@karl-dau - Alas, I did not. If I recall correctly - and it's been a while now - we just ended up using func Foo(inputPtr []Flarp, inputLen uint) uint64 ~and ignoring the inputLen parameter~.
Sorry for late reply lol. It wasn't possible since size is a very tricky thing in C, almost impossible to do it correctly automatically. There is a size tip but it has no real effect, just to mark things for better readability in YAML.
Maybe it will be solved in the future.