Bug 10139 – std.stdio.writef and friends documentation is severely out of date
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-22T19:39:00Z
Last change time
2014-09-20T20:46:03Z
Keywords
pull
Assigned to
nobody
Creator
gdkslpmq
Comments
Comment #0 by gdkslpmq — 2013-05-22T19:39:20Z
According to the std.stdio page on the D website, the behaviour of writef should be:
"If the first argument args[0] is a FILE*, use the format specifier in args[1] to control the formatting of args[2..$], and write the resulting string to args[0]. If arg[0] is not a FILE*, the call is equivalent to writef(stdout, args)."
However, this program
import std.stdio;
void main() {
writef(stderr.getFP(), "hi");
}
fails to compile with the error
/usr/include/d/std/stdio.d(1756): Error: template std.stdio.File.writef does not match any function template declaration. Candidates are:
/usr/include/d/std/stdio.d(752): std.stdio.File.writef(Char, A...)(in Char[] fmt, A args)
/usr/include/d/std/stdio.d(1756): Error: template std.stdio.File.writef(Char, A...)(in Char[] fmt, A args) cannot deduce template function from argument types !()(shared(_iobuf)*,string)
test.d(5): Error: template instance std.stdio.writef!(shared(_iobuf)*,string) error instantiating
z
Comment #1 by schveiguy — 2013-05-22T20:22:05Z
The docs are wrong. They need updating.
use stderr.writef instead of writef(stderr ...).
global writef is now simply a forwarding call to stdout.writef.