How to call a C function from D that takes a FILE * as an argument?
Seb
seb at wilzba.ch
Wed Jul 4 02:16:00 UTC 2018
On Wednesday, 4 July 2018 at 02:08:11 UTC, Joe wrote:
> On Wednesday, 4 July 2018 at 01:58:15 UTC, Seb wrote:
>> So just add the declaration to your D file:
>>
>> ---
>> extern(C) void myCfunction(FILE* stream);
>> ---
>
> I do have a similar declaration in D. It appears the problem
> is that the C program I'm trying to convert passes stdout as
> the argument and the D compiler complains somewhat like the
> following:
>
>
> Error: function foo.main.myCfunction (shared(_IO_FILE)* stream)
> is not callable using argument types (File)
>
> So I guess the question is what to pass instead of stdout.
Hmm, calling e.g. fprintf with stdout should just work:
---
void main()
{
import core.stdc.stdio;
fprintf(stdout, "Hello %s", "world".ptr);
}
---
Could you maybe provide your whole code?
More information about the Digitalmars-d-learn
mailing list