On Thursday, 7 March 2019 at 21:50:17 UTC, Johannes Loher wrote:
```
enum profile_scope(string name) = "import core.stdc.stdio : printf;
printf(\""
    ~ name ~ "\n\"); scope(exit) printf(\"" ~ name ~ "\n\");";

extern (C) void main()
{
    mixin(profile_scope!"func1");
}

```
This uses string concatenation only at compile time and not during run time, so it does not require the garbage collector and is compatible
with betterC :)

Thanks, this works flawlessly. Out of interest: what is the "enum" doing there? I had the exact same behaviour in a function before, that I only called at compile-time, so why did it complain then? Can I somehow tell the compiler that a function should only be available at compile-time?

Reply via email to