lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


The problem in your task is, that you want to use the "specificly
c-variadic function" vsnprintf.

There is no easy way from "variadic world of Lua" to "variadic world of C".

But if you do NOT have the ambition to give the work to the "variadic
world of C", but are capable to do some work yourself, then generally
the handling of "variadic Lua functions" in C I think is quite
straight forward (and much more powerful / secure than "handlich C
variadic argument lists" (please understand that the function group
printf has the bad reputation of being extremely sensitive to
programming mistakes... any unexpected format string there can easily
crash a complete C application into some "very strange nirvana
state")).

To see, how such a "variadic Lua function" should be handled
correctly, please best look at the programming of function str_format
in lua source file strlib.c .


Am Mo., 8. Aug. 2022 um 14:43 Uhr schrieb Jairo A. del Rio
<jairoadelrio6@gmail.com>:
>
> Hi, list. I want to ask you about this:
>
> https://stackoverflow.com/questions/50563785/how-to-wrap-a-c-function-with-variable-arguments-using-swig/50673219
>