[Issue 927] New: writefln() is duplicating values for parameters supplied
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Feb 3 10:43:15 PST 2007
http://d.puremagic.com/issues/show_bug.cgi?id=927
Summary: writefln() is duplicating values for parameters supplied
Product: D
Version: 1.00
Platform: Macintosh
OS/Version: Mac OS X
Status: NEW
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: bugzilla at digitalmars.com
ReportedBy: rmann-d-lang at latencyzero.com
I'm not sure if it's just something I did wrong, but I'm getting the wrong
value output from writefln.
template
MakeFourCharCode(char[] inS)
{
static assert(inS.length == 4);
const FourCharCode MakeFourCharCode = (inS[0] << 24)
|
(inS[1] << 16)
|
(inS[2] << 8)
|
inS[3];
}
char[]
FourCharCodeAsString(FourCharCode inVal)
{
char[4] s;
s[0] = (inVal >> 24 & 0xFF);
s[1] = (inVal >> 16 & 0xFF);
s[2] = (inVal >> 8 & 0xFF);
s[3] = (inVal >> 0 & 0xFF);
return s;
}
foo()
{
FourCharCode val1 = MakeFourCharCode!("cntl");
uint val2 = 4;
writefln("SketchViewDrawHandler called. Class: '%s', Kind: %s ('%s')",
FourCharCodeAsString(val1),
val2,
FourCharCodeAsString(MakeFourCharCode!("abcd")));
}
Output of foo:
SketchViewDrawHandler called. Class: 'cntl', Kind: 4 ('cntl')
I expected:
SketchViewDrawHandler called. Class: 'cntl', Kind: 4 ('abcd')
(I originally had put val2 as the argument where "abcd" is, with appropriate
casting, but then I switched to "abcd" as an experiment).
--
More information about the Digitalmars-d-bugs
mailing list