| Thread overview | ||||||||
|---|---|---|---|---|---|---|---|---|
|
March 18, 2015 calling C variadic arguments with no 'argc' and only variadic arguments | ||||
|---|---|---|---|---|
| ||||
So I ported the C API for MathGL to D, and it is up at code.dlang.org (under dmathgl). MathGL is a nice plotting library. http://mathgl.sourceforge.net/doc_en/Pictures.html#Pictures Later I will work on porting the C++ interface, but so far it at least works for the simplest sample. (Not tried anything else as they are all written in C++). 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? | ||||
March 18, 2015 Re: calling C variadic arguments with no 'argc' and only variadic arguments | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Laeeth Isharc | sorry - posted in wrong forum
On Wednesday, 18 March 2015 at 00:54:07 UTC, Laeeth Isharc wrote:
> So I ported the C API for MathGL to D, and it is up at code.dlang.org (under dmathgl). MathGL is a nice plotting library.
>
> http://mathgl.sourceforge.net/doc_en/Pictures.html#Pictures
>
> Later I will work on porting the C++ interface, but so far it at least works for the simplest sample. (Not tried anything else as they are all written in C++).
>
> 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?
| |||
March 18, 2015 Re: calling C variadic arguments with no 'argc' and only variadic arguments | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Laeeth Isharc | "Laeeth Isharc" wrote in message news:jmlgralvzaqperfkntqw@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. | |||
March 18, 2015 Re: calling C variadic arguments with no 'argc' and only variadic arguments | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Daniel Murphy | On Wednesday, 18 March 2015 at 03:14:30 UTC, Daniel Murphy wrote:
> "Laeeth Isharc" wrote in message news:jmlgralvzaqperfkntqw@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.
Thanks. I should have double checked but trusted dstep which
seems to have gotten confused by these ones. Its a great time
saver generally though.
Laeeth
| |||
March 18, 2015 Re: calling C variadic arguments with no 'argc' and only variadic arguments | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Laeeth Isharc | On 2015-03-18 05:49, Laeeth Isharc wrote: > Thanks. I should have double checked but trusted dstep which > seems to have gotten confused by these ones. Its a great time > saver generally though. Please report any issues with DStep to [1]. [1] http://github.com/jacob-carlborg/dstep/issues -- /Jacob Carlborg | |||
March 18, 2015 Re: calling C variadic arguments with no 'argc' and only variadic arguments | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | On Wednesday, 18 March 2015 at 16:14:28 UTC, Jacob Carlborg wrote:
> On 2015-03-18 05:49, Laeeth Isharc wrote:
>
>> Thanks. I should have double checked but trusted dstep which
>> seems to have gotten confused by these ones. Its a great time
>> saver generally though.
>
> Please report any issues with DStep to [1].
>
> [1] http://github.com/jacob-carlborg/dstep/issues
Was just about to ;)
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply