www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - core.stdc.stdio.stderr != std.stdio.stderr ?

reply bearophile <bearophileHUGS lycos.com> writes:
Is this all correct?


static import core.stdc.stdio;
static import std.stdio;
void main() {
    std.stdio.fprintf(core.stdc.stdio.stderr, "Error\n"); // OK
    std.stdio.fprintf(std.stdio.stderr, "Error\n"); // line 5, error
}

The latest DMD gives:

test.d(5): Error: function core.stdc.stdio.fprintf (shared(_iobuf)* stream, in
const(char*) format,...) is not callable using argument types (File,string)
test.d(5): Error: cannot implicitly convert expression (stderr) of type File to
shared(_iobuf)*

Bye,
bearophile
Aug 19 2011
next sibling parent "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Fri, 19 Aug 2011 10:12:11 -0400, bearophile <bearophileHUGS lycos.com>  
wrote:

 Is this all correct?


 static import core.stdc.stdio;
 static import std.stdio;
 void main() {
     std.stdio.fprintf(core.stdc.stdio.stderr, "Error\n"); // OK
     std.stdio.fprintf(std.stdio.stderr, "Error\n"); // line 5, error
 }

 The latest DMD gives:

 test.d(5): Error: function core.stdc.stdio.fprintf (shared(_iobuf)*  
 stream, in const(char*) format,...) is not callable using argument types  
 (File,string)
 test.d(5): Error: cannot implicitly convert expression (stderr) of type  
 File to shared(_iobuf)*
Yes, std.stdio.stderr is a D File struct, whereas core.stdc.stdio.stderr is a C FILE * opaque type. -Steve
Aug 19 2011
prev sibling parent David Nadlinger <see klickverbot.at> writes:
On 8/19/11 4:12 PM, bearophile wrote:
 static import core.stdc.stdio;
 static import std.stdio;
 void main() {
      std.stdio.fprintf(core.stdc.stdio.stderr, "Error\n"); // OK
      std.stdio.fprintf(std.stdio.stderr, "Error\n"); // line 5, error
 }
std.stdio.stderr is a wrapper around core.stdc.stdio.stderr (a D File), you can use std.stdio.stderr.getFP() to get the C FILE pointer from it. David
Aug 19 2011