On Friday, 10 August 2018 at 09:57:53 UTC, learnfirst1 wrote:
        T!(t => {
                printf("test 2 name = %s\n".ptr, t.name.ptr);
        }, "test") ; // build error

This is not doing what you think it's doing. The syntax t => { return t; } is equivalent to t => () => t. That is, it's returning a function that takes no arguments, not a value.

For that very same reason, if you compile and run your code without -betterC, only the first printf() will be executed, and only one line of output will be generated.

What you should do instead is:
    T!((t){
            printf("test 2 name = %s\n".ptr, t.name.ptr);
        }, "test");

(note the lack of the => arrow)

--
  Simen

Reply via email to