我正在学习 D,并且对我遇到的错误感到困惑。
考虑以下:
module helloworld;
import std.stdio;
import std.perf;
ptrdiff_t main( string[] args )
{
auto t = new PerformanceCounter; //From managed heap
//PerformanceCounter t; //On the stack
t.start();
writeln( "Hello, ", size_t.sizeof * 8, "-bit world!" );
t.stop();
writeln( "Elapsed time: ", t.microseconds, " \xb5s." );
return 0;
} //main()
产生一个非常可敬的:
Hello, 32-bit world!
Elapsed time: 218 µs.
现在考虑当我尝试在堆栈上初始化 PerformanceCounter 而不是使用托管堆时会发生什么:
//auto t = new PerformanceCounter; //From managed heap
PerformanceCounter t; //On the stack
产量:
--- killed by signal 10
我难住了。关于为什么会中断的任何想法?(Mac OS X 10.6.4 上的 DMD 2.049)。在此先感谢您对 n00b 的帮助。