How to call a C function from D that takes a FILE * as an argument?

Joe jma at freedomcircle.com
Wed Jul 4 02:54:47 UTC 2018


On Wednesday, 4 July 2018 at 02:16:00 UTC, Seb wrote:
> 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?

This short test program shows the error:

---
import std.stdio;


void main()
{
     extern (C) void list(FILE *fd);
     list(stdout);
}
---

Now I fixed this by changing the import to core.stdc.stdio. I 
guess the problem is if you import std.stdio (which brings in the 
other one), there are two slightly incompatible stdout's and the 
D takes precedence.


More information about the Digitalmars-d-learn mailing list