The X Macro using D

Johan Engelen via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 21 12:26:05 PDT 2017


On Thursday, 20 July 2017 at 21:17:45 UTC, Walter Bright wrote:
> Some time ago, I wrote about the X Macro in C:
>
>   https://digitalmars.com/articles/b51.html
>
> I used it from time to time in C code. It's one of the things I 
> actually like about the C preprocessor. But in translating the 
> aged C code to D it was time to make X work in D. Here's the C 
> code, followed by the D translation.

This mechanism is used in LLVM in a number of places, where the 
list entries are used e.g. to populate tables and to define 
aggregate member fields.
For example:
https://github.com/llvm-mirror/compiler-rt/blob/master/lib/profile/InstrProfData.inc#L29-L51




More information about the Digitalmars-d mailing list