bottlenoselabs / c2cs

Generate C# bindings from a C header.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`va_list`

lithiumtoast opened this issue · comments

Found when generating bindings for flecs: https://github.com/SanderMertens/flecs

/* Append format string with argument list to a buffer.
 * Returns false when max is reached, true when there is still space */
FLECS_API
bool ecs_strbuf_vappend(
    ecs_strbuf_t *buffer,
    const char *fmt,
    va_list args);

It's not clear how va_list should be handled.

There is some discussion here on a similar issue: dotnet/runtime#9316

It's my understanding that for flecs, functions which use va_list which are exported are optional. Short term solution is to ignore any exported function which has va_list in the parameters.

There is no immediate clear way to proceed with this. Best to tread water on this and look into it again at a future date.

For now, va_list is remapped into IntPtr where necessary to avoid compilation errors.

@mfkl Thanks.

va_list reading seems hard to do in a cross-platform way. Each platforms has its own implementation and I'm not sure it would work.

Rough. I'm working on adding support for multi-pass so that Clang can parse the translation unit using cross-compilation. Once that is finished I can expand the integration tests to do a dry-run of calling C# bindgen code for each platform and see what passes / fails. From there I can tackle this and add support for va_list but it will be limited by what hardware I have available either on cloud or in house.

Now that multi-pass is in, I'm taking a look at this again. While it would be interesting to do, I don't think I'm very interested in adding support right now myself. If someone wants to take a crack at it, I'm always open to contributions.