3 ms·
That's just: ``` #define MACRO(...) F(__VA_ARGS__); G(__VA_ARGS__) ``` The technique in the article is more often used to type check the individual parameters
by viega 1y ago
That's just:
```
#define MACRO(...) F(__VA_ARGS__); G(__VA_ARGS__)
```
The technique in the article is more often used to type check the individual parameters, or wrap a function call around them individually, etc.
- hyperhello 1y agoOk. How about into F(a,”a”);F(b,”b”);etc. The problem being automating enums and their names in one call. Like MACRO(a,b,c) and getting a map from a to “a”.
- viega 1y ago100%, that's definitely easy to do once you understand the technique.
- hyperhello 1y agoPlease?
- viega 1y agoI'm on my phone, but if you start with the top 8 lines in the code box under the ascii art, you'll get an implementation of `H4X0R_MAP()`; the bottom two lines are an example, and you can just write yourself a body that produces one term. Only thing you need to know beyond that is the stringify operator.
- viega 1y agoAnd I should say, if you want to apply the same transformation to arguments twice, but call F() separately from G() per your starting example, you'd just apply your map twice in your top-level macro.
- WalterBright 1y ago> if you want to apply the same transformation to arguments twice, but call F() > separately from G() per your starting example, you'd just apply your map twice in your top-level macro My brain just blew a fuse.