Why won't this compile using DMD?
Ivan Trombley
itrombley at dot-borg.org
Sun Aug 12 00:39:13 PDT 2012
I'm stumped. Can anyone tell me why this won't compule using DMD
(v2.060)? It compiles and runs just fine using GDC:
import std.stdio;
import std.concurrency;
shared class Data
{
public:
this(int count)
{
m_count = count;
}
int count() const
{
return m_count;
}
private:
int m_count = void;
}
int main()
{
Tid tid = spawn(&threadFunc, thisTid);
while (true)
{
auto data = receiveOnly!(Data);
writefln("Count is %s.", data.count);
if (data.count == 0)
break;
}
return 0;
}
void threadFunc(Tid owner)
{
for (int count = 10; count >= 0; --count)
{
auto data = new Data(count);
send(owner, data);
}
}
The errors I get from DMD are:
test.d(27): Error: function test.Data.count () shared const is
not callable using argument types ()
test.d(29): Error: function test.Data.count () shared const is
not callable using argument types ()
/usr/include/dmd/phobos/std/concurrency.d(467): Error: static
assert "Aliases to mutable thread-local data not allowed."
test.d(41): instantiated from here: send!(Data)
More information about the Digitalmars-d
mailing list