CTFE write message to console

Carl Sturtivant sturtivant at gmail.com
Thu Apr 4 15:43:55 UTC 2024


On Thursday, 4 April 2024 at 15:07:21 UTC, Richard (Rikki) Andrew 
Cattermole wrote:
>
> Ah yes, I forgot about that particular thing, doesn't see much 
> use as far as I'm aware.
>
> It should be working though.

```D
enum X = computeX("A message");

string computeX(string msg) {
     auto s = "CTFE msg: ";
     auto x = imported!"std.format".format("%s%s\n", s, msg);
     __ctfeWrite(x);
     return x;
}

void main() {
     import std.stdio;
     writeln(X);
}
```
Produces no output on compilation, and writes out `CTFE msg: A 
message` when run.



More information about the Digitalmars-d-learn mailing list