Board index » delphi » varargs syntax

varargs syntax

In Delphi 6,

this does not compile:

type
  TTestProc = function(i : integer; firstArg : Byte) : Integer; cdecl;
varargs;

After some trial and error, I can get this to compile:

type
  TTestProc = function(i : integer; firstArg : Byte) : Integer; cdecl;
varargs=Byte;

Can anyone explain the correct syntax for varargs. Online help is bare on
the matter.

Regards.

 

Re:varargs syntax


In article <3b9cd487_1@dnews>, Rob says...

Quote
> In Delphi 6,

> this does not compile:

> type
>   TTestProc = function(i : integer; firstArg : Byte) : Integer; cdecl;
> varargs;

The syntax is correct, but varargs only work for external declarations,
e.g. declarations of functions in a C dll.

So it seems they are not allowed for function pointers, or for your own
code.
--
Rudy Velthuis (TeamB)

Re:varargs syntax


Quote
: "Rob" <robzli...@S.P.A.M.myrealbox.com> wrote:
>  TTestProc = function(i : integer; firstArg : Byte) : Integer; cdecl;
>varargs;

  TTestProc = function(i : integer; firstArg : Byte) : Integer
     cdecl varargs;

The semicolons that everybody seems to love are just barely accepted by
the compiler as a courtesy.

Quote
>type
>  TTestProc = function(i : integer; firstArg : Byte) : Integer; cdecl;
>varargs=Byte;

That should never compile.

Re:varargs syntax


In article <3b9cd487_1@dnews>
        "Rob" <robzli...@S.P.A.M.myrealbox.com> wrote:

Quote
> In Delphi 6,

> this does not compile:

> type
>   TTestProc = function(i : integer; firstArg : Byte) : Integer; cdecl;
> varargs;

> After some trial and error, I can get this to compile:

> type
>   TTestProc = function(i : integer; firstArg : Byte) : Integer; cdecl;
> varargs=Byte;

Congratulations. You've just defined a new type, called "varargs", which
is an alias for Byte.

It does nothing to the function pointer specification. You want to
remove two semicolons:

type
  TTestProc = function(i : integer; firstArg : Byte) : Integer cdecl
    varargs;

-- Barry

--
  If you're not part of the solution, you're part of the precipitate.
Team JEDI: http://www.delphi-jedi.org
NNQ - Quoting Style in Newsgroup Postings
  http://web.infoave.net/~dcalhoun/nnq/nquote.html

Re:varargs syntax


In article <6l7qpt074vtr4ekjahr2dmm4fcenumu...@4ax.com>
        K Wak <so...@no.email> wrote:

Quote
> >type
> >  TTestProc = function(i : integer; firstArg : Byte) : Integer; cdecl;
> >varargs=Byte;

> That should never compile.

Oh, it should - it just doesn't do what Rob thinks it does.

-- Barry

--
  If you're not part of the solution, you're part of the precipitate.
Team JEDI: http://www.delphi-jedi.org
NNQ - Quoting Style in Newsgroup Postings
  http://web.infoave.net/~dcalhoun/nnq/nquote.html

Re:varargs syntax


Thanks for the responses, as pointed out, the solution is only to have one
semicolon at the end of the declaration.

Re:varargs syntax


In article <63qqpt8qj5qeus6fsd1l532q1g7f5nf...@4ax.com>, Barry Kelly
says...

Quote
> > >type
> > >  TTestProc = function(i : integer; firstArg : Byte) : Integer; cdecl;
> > >varargs=Byte;

> > That should never compile.

> Oh, it should - it just doesn't do what Rob thinks it does.

Indeed, it defines varargs as an identifier. Possible, since varargs is
not a keyword, only a directive.
--
Rudy Velthuis (TeamB)

Other Threads