calling C variadic arguments with no 'argc' and only variadic arguments

Daniel Murphy via Digitalmars-d digitalmars-d at puremagic.com
Tue Mar 17 20:14:31 PDT 2015


"Laeeth Isharc"  wrote in message 
news:jmlgralvzaqperfkntqw at forum.dlang.org...

> DMD gave me an error message for the following declarations:
>
> double mgl_rnd (...);
> double mgl_rnd_ (...);
>
> It says I need at least one fixed argument first.  But the C headers are 
> as they are.
>
> I could work around this by writing a C stub
>
> double mgl_rnd_(int dummy, ...)
>
> but is there any way to call these functions without this workaround?

You should just declare them with the actual argument types.  From a quick 
look at the documentation it seems like the correct signature would be
double mgl_rnd();

i.e. these functions aren't actually variadic they just haven't specified 
the signature.  Functions that take variadic arguments will pretty much 
always have at least one named argument. 



More information about the Digitalmars-d mailing list