On Thursday, 29 June 2023 at 18:27:22 UTC, Cecil Ward wrote:
I’m trying to debug my D program with old-fashioned printfs
stuck in various strategic places, actually using writefln().
My problem is that the addition of printf fights with the
existing declarations for pure nothrow @nogc @safe and I have
to adjust them, then put them back correctly when the
writefln() trace statements are later removed.
Is there something else I could be using, something that is
allowed to violate the checking rules for purity, nothrow,
@nogc? Would pragma( msg, "…" ) do the trick? Is that what I
should be using?
pragma(msg, "") is only for compile time. It for debugging
functions/templates if they're actually used (which static path
is used), instantiated, and you can also get type values from
template inputs to confirm they're what you expect. "Oh this is a
char[][] not a char[]!"
pragmas are the D equivalent of C/C++ pragmas. In this case,
C/C++:
```C
#pragma message( message-string )
```