Just in case I ever think “oh, I might try want to go the Variadic function arguments way in Delphi” again, I must remember “maybe not a good idea” and re-read these posts:
- [Wayback/Archive] Variadic function – Wikipedia which in C is implemented with in [Wayback/Archive]
varargs.h
– Wikipedia (now in [Wayback/Archive]stdarg.h
– Wikipedia) with the identifiersva_list
,va_start
,va_arg
, andva_end
. - [Wayback/Archive] Delphi “array of const” to “varargs” – Stack Overflow with great insights from former Delphi compiler developer [Wayback/Archive] Barry Kelly.
- [Wayback/Archive] E2591 Only
cdecl
functions may usevarargs
(Delphi) – RAD Studio (I already knew this, but it is good to have that bit linked here as well) - [Wayback/Archive] gmp-wrapper-for-delphi/gmp_lib.pas at master · EricGrange/gmp-wrapper-for-delphi · GitHub with an example how
varargs
support got introduced in Delphi 6: forexternal cdecl
functions. - [Wayback/Archive] Rudy’s Delphi Corner – Pitfalls of converting (still *the* reference article on translating C/C++ headers to Delphi) has this on
varargs
:
Fortunately, since Delphi 6, you can declare external functions like
wsprintf
using thevarargs
directive. - [Wayback/Archive] How to create a Delphi variadic method similar to Write/Writeln without requiring brackets for arguments? – Algorithms, Data Structures and Class Design – Delphi-PRAXiS [en] has a nice 64-bit Delphi example using the undocumented Delphi identifiers
TVarArgList
,VarArgStart
,VarArgGetValue
, andVarArgEnd
.
Note that this example, despite the description indicates it is, it is actually not varargs
by array of const
(which requires using TVarRec
as under the hood it is an open array of TVarRec
): [Wayback/Archive] How to create functions that can accept variable number of parameters such as Format().
Then some Free Pascal links, which is different from, but also similar to Delphi:
- [Wayback/Archive] varargs in function/procedure definitions
- [Wayback/Archive] Equivalent to stacking varargs – page? 1
- [Wayback/Archive] Equivalent to stacking varargs – page 2
Queries:
--
jeroen