x-macros Questions

8

Solved

I just learned of X-Macros. What real-world uses of X-Macros have you seen? When are they the right tool for the job?
Insurgency asked 9/7, 2011 at 15:56

2

I am curious if any of you can think of a way upon macro expansion to repeat the macro itself. Here is an incredibly small scale version of an overall bigger problem: #include<stdio.h> #defi...
Underbelly asked 30/1, 2023 at 17:20

1

Solved

It occurred to me that the following would be a preferable style of X-macro trick: #define LIST_OF_COLOURS(X) \ X(RED) \ X(GREEN) \ X(BLUE) #define LIST_OF_FRUIT(X) \ X(APPLE) \ X(ORANGE) \ ...
Tanka asked 18/7, 2019 at 5:39

2

Solved

It could be argued that in many cases X-macros increase safety, because it makes easier to make sure that generated arrays are the same length for example. However, Misra C (from 2004 reference)...
William asked 27/9, 2018 at 8:1

3

Solved

Is there any way in standard C—or with GNU extensions—to append stuff to a macro definition? E.g., given a macro defined as #define List foo bar can I append bas so that it List expands as if I’d d...
Homoiousian asked 28/12, 2010 at 22:34

2

Solved

Related to this question on Software Engineering about easily serializing various struct contents on demand, I found an article which uses x-macros to create struct metadata needed for "out of the ...
Pyramidon asked 15/8, 2017 at 13:0

2

A while ago, I wrote a set of X-macros for a largish project. I needed to maintain coherent lists of both strings and enumerated references/hash values/callback functions etc. Here is what the func...
Decuple asked 21/2, 2011 at 13:55
1

© 2022 - 2024 — McMap. All rights reserved.