How do you debug @safe @nogc code? Can't figure out how to print.
Neia Neutuladh
neia at ikeran.org
Sat Nov 17 21:56:23 UTC 2018
On Sat, 17 Nov 2018 21:16:13 +0000, aliak wrote:
> Could do. But it's not scalable. I'd have to comment out all the
> unittests that call the template function with a T that allocates inside
> the @nogc template (if I understood you correctly that it)
I meant something like:
void debugln(T...)(T args) @nogc
{
import std.stdio;
debug(MyProject) writeln(args);
}
You use that function instead of writeln in your @nogc-compatible
templates:
void callFunc(alias func)()
{
debugln("about to call function!");
func();
debugln("done calling function!");
}
Then I can write:
@nogc:
void foo() { printf("hello world\n"); }
void main() { callFunc!foo(); }
More information about the Digitalmars-d-learn
mailing list