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

2018-07-04 Thread WebFreak001 via Digitalmars-d-learn
On Wednesday, 4 July 2018 at 02:54:47 UTC, Joe wrote: 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

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

2018-07-03 Thread Adam D. Ruppe via Digitalmars-d-learn
On Wednesday, 4 July 2018 at 02:54:47 UTC, Joe wrote: 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. If you import both

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

2018-07-03 Thread Joe via Digitalmars-d-learn
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:

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

2018-07-03 Thread Seb via Digitalmars-d-learn
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

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

2018-07-03 Thread Joe via Digitalmars-d-learn
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

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

2018-07-03 Thread Seb via Digitalmars-d-learn
On Wednesday, 4 July 2018 at 01:06:36 UTC, Joe wrote: The subject basically says it all. The C function uses the argument to call fprintf and also passes it to other functions where it's used to call fileno, fprintf or putc. Like you would with C's fprintf

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

2018-07-03 Thread Joe via Digitalmars-d-learn
The subject basically says it all. The C function uses the argument to call fprintf and also passes it to other functions where it's used to call fileno, fprintf or putc.