Is there a way to pass a kotlin vararg to a variad...
# kotlin-native
r
Is there a way to pass a kotlin vararg to a variadic C function? I'm trying to pass through a printf-style log callback to
snprintf
to do the actual formatting but I've been unable to find a way to do it. At this point I'm thinking of trying a convoluted approach of writing a C method that I can pass as the initial callback that will do the snprintf in C code, then callback into my kotlin code with the final string.
e
variadics are hard. https://youtrack.jetbrains.com/issue/KT-42925 & related
c
No no no no. I suffered for 2 days figuring it out. Simply no.
C does not have vararg pass through
That's why va_list exists
r
Ahh right, vsprintf. Is it possible to use that with Kotlin/Native? ­čÖĆ
c
Yes, You can use a vararg function. You just can't pass through a vararg
You can create a va_list