After the address of "a,"b" and "c" on stack arg will be any other address of stack space but not NULL ?
(Maybe I use it wrong in this case please show me the right code)
sub test cdecl(byref first as string,...)
dim as zstring ptr arg
dim as Cva_List list
Cva_Start(list, first)
arg=strptr(first)
while arg
print arg,*arg,"press any key"
arg = Cva_Arg(list, Any Ptr)
sleep
wend
end sub
test("a", "b", "c")
sleep
Last edited by D.J.Peters on Jul 16, 2022 19:51, edited 1 time in total.
sub test cdecl(byref first as string,...)
dim as zstring ptr arg
dim as Cva_List list
Cva_Start(list, first)
arg=strptr(first)
while arg
print arg,*arg,"press any key"
arg = Cva_Arg(list, Any Ptr)
wend
end sub
test( "a", "b", "c", 0 ) '' <<<< ---- NULL (0) stops the list
sleep
.....
The fixed parameters(s) can provide information about how many variadic arguments there are, by an unspecified mechanism.
Otherwise a terminal argument can be added in the variable length argument list, but this reserves a special argument value forbidden to the useful variadic arguments.
(if one choose to pass the variable arguments all by pointer, in this case an obvious terminal argument is the null pointer)
.....
..... Cva_Start (or Cva_Copy) is like a constructor (or a copy-constructor) for the variadic argument_list object and must finally have a matching call to Cva_End, which is like a destructor.
After Cva_End for argument_list has been called, argument_list can be reused and reinitialized with another call to Cva_Start (or Cva_Copy).
The Cva_Start (or Cva_Copy) and Cva_End calls must both be called in pairs in the same procedure (for cross platform compatibility).
.....