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

Re: Is there any way to receive or pass an argument of C type "va_list"?


On 4/4/24 18:01, Jussi Lahtinen wrote:
    If not possible in Gambas, would a C program be able to process a va_list if it's pointer was passed to it?


I'm a bit confused...  the example you sent (TestCommandical) used "va_list" to interact with Gambas side.
What exactly do you mean?


Jussi


No, it used a function that accepted variadic arguments to receive an integer, the array of structs, and OPTION_END. It's signature consisted of one parameter plus variadic parameters.

int parse_options (int count, ...)
{
  va_list ap;
  int ret;

  va_start (ap, count);
  ret = parse_options_va (count, ap);
  va_end (ap);
  return ret;
}

That function then slurped the variadic arguments into a va_list and passed that to parse_options_va().

int parse_options_va (int count, va_list ap)
{
  ...
}

I need to know if there is a way, or not, to pass or receive a va_list type directly to an external function or by a Gambas function (a callback). If not in Gambas, then perhaps I could write my own shared C library to do va_list conversions.

According to this /old/ StackOverflow post [1], "The va_list type is an array containing a single element of one structure containing the necessary information to implement the va_arg macro." I'm guessing that I could pass a pointer to a C function that would parse the va_list for me, but I am unsure about that.

[1] https://stackoverflow.com/questions/4958384/what-is-the-format-of-the-x86-64-va-list-structure


--
Lee

--- Gambas User List Netiquette [https://gambaswiki.org/wiki/doc/netiquette] ----
--- Gambas User List Archive [https://lists.gambas-basic.org/archive/user] ----


Follow-Ups:
Re: Is there any way to receive or pass an argument of C type "va_list"?T Lee Davidson <t.lee.davidson@xxxxxxxxx>
References:
Is there any way to receive or pass an argument of C type "va_list"?T Lee Davidson <t.lee.davidson@xxxxxxxxx>
Re: Is there any way to receive or pass an argument of C type "va_list"?Jussi Lahtinen <jussi.lahtinen@xxxxxxxxx>