Answer the question
In order to leave comments, you need to log in
How to translate optional parameters from C to Delphi?
When translating functions from C to Delphi, I encountered an interesting moment, in the header file in C, there is such a function declaration: The
question is how to correctly implement this function in Delphi (my version, only the first two parameters)?
function Vix_GetProperties(handle: VixHandle;
firstPropertyID: VixPropertyID
): VixError; cdecl; external 'vix.dll';
Answer the question
In order to leave comments, you need to log in
function Vix_GetProperties(
handle: VixHandle;
firstPropertyID: VixPropertyID
): VixError; cdecl varargs; external 'vix.dll';
Only by passing parameters in an array.
procedure TForm1.Display(X: array of const);
var
I: Integer;
begin
for I := Low(X) to High(X) do
...
end;
Display([42, 1.234, 'A', 'Васек Трубачев', Form1, TButton]);
Vix_GetProperties
works similarly WriteLn
with a list.
Predefined constants, types, procedures, and functions (such as True, Integer, or Writeln) do not have actual declarations.Instead they are built into the compiler and are treated as if they were declared at the beginning of the System unit.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question