c2cs icon indicating copy to clipboard operation
c2cs copied to clipboard

`va_list`

Open lithiumtoast opened this issue 4 years ago • 5 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: https://github.com/dotnet/runtime/issues/9316

lithiumtoast avatar Apr 28 '21 16:04 lithiumtoast

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.

lithiumtoast avatar Apr 28 '21 16:04 lithiumtoast

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.

lithiumtoast avatar May 24 '21 01:05 lithiumtoast

heya, this might interest you https://github.com/jeremyVignelles/va-list-interop-demo

mfkl avatar Mar 17 '22 06:03 mfkl

@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.

lithiumtoast avatar Apr 01 '22 03:04 lithiumtoast

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.

lithiumtoast avatar Apr 24 '22 02:04 lithiumtoast

With usage of DisableRuntimeMarshallingAttribute .NET variadic argument method signatures are not supported; closing this out because DisableRuntimeMarshallingAttribute is what should be used for .NET 7+ with C2CS generated bindings.

lithiumtoast avatar Jul 21 '23 21:07 lithiumtoast