Thread overview | |||||
---|---|---|---|---|---|
|
August 03, 2016 q about bindings to C (noob) | ||||
---|---|---|---|---|
| ||||
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? } |
August 03, 2016 Re: q about bindings to C (noob) | ||||
---|---|---|---|---|
| ||||
Posted in reply to RomanZ | 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 |
August 03, 2016 Re: q about bindings to C (noob) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jacob Carlborg | thanks. |
Copyright © 1999-2021 by the D Language Foundation