1
votes

I'm learning D and having some difficulty with a standard library import.

import std.stdio;

void main(string[] args) {
    fwritefln(stderr, "foo");
}

Compiling with "gdc foo.d" produces the following error

foo.d:4: error: undefined identifier fwritefln, did you mean template writefln(T...)(T args)?

I can't figure out what I'm doing wrong. Most library imports I've tried, I've had no difficulty with, but for some reason, this "fwritefln" is a problem.

2

2 Answers

4
votes

Try this:

stderr.writefln(...);

This is the D's equivalent to C's fprintf(stderr, ...)

Every OutputStream has set of writef* methods that can be used to send formatted strings. More about it here: http://dlang.org/phobos/std_stream.html#.OutputStream.writef

1
votes

Well like the error already suggests change "fwritefln" to "writefln".

It seems to be a misspelling error on your side.

There is no fwritefln in the std.stdio module: http://dlang.org/phobos/std_stdio.html