q about bindings to C (noob)
Jacob Carlborg via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Wed Aug 3 02:07:32 PDT 2016
On 2016-08-03 10:27, RomanZ wrote:
> version(RefOut)
> extern(C) void fun(out int input, ref in output);
> else
> extern(C) void fun( /*[out]*/ int* input, const(float)* output);
>
> version = RefOut;
> void main() {
> int input;
> float output;
> fun( input, output ); // work fine; is it correct binding? or where
> the trouble?
> }
It should work. It depends on how close you would like the D code to be
to the C code. For example, the C code requires to pass pointers where
in the D code this will handled automatically.
Note also that "out" parameters are automatically reset to there .init
value when passed to a function.
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list