assert(__ctfe) and betterC

Steven Schveighoffer schveiguy at gmail.com
Wed Jan 27 21:27:45 UTC 2021


On 1/27/21 4:05 PM, Tim wrote:
> On Wednesday, 27 January 2021 at 20:59:24 UTC, Steven Schveighoffer wrote:
>> Is there another way I can do this?
>>
> 
> One way I have sometimes used is an alias to a function literal:
> 
> alias generateVar = function(string name) {
>      return "int " ~ name ~ ";";
> };
> 
> mixin(generateVar("i"));
> 
> extern(C) int main()
> {
>      i = 0;
>      return i;
> }
> 
> This works with betterC.

Well, that works great! What a nice... well, I have no idea why this 
works. But thank you!

-Steve


More information about the Digitalmars-d mailing list