...
Code Block |
---|
enum Color { Color_Red, Color_Green, Color_Blue };
static const struct {
enum Color color;
const char *name;
} colors[] = {
#define COLOR(color) { Color_ ## color, #color }
COLOR(Red), COLOR(Green), COLOR(Blue)
};
See [ |
calculates only one of the two expressions depending on the selector's value. See PRE05-C.
...
...
...
...
...
...
...
...
...
...
for
...
more
...
information
...
calculates only one of the two expressions depending on the selector's value.
PRE00-EX3: Macros can be used to yield a compile-time constant. This is not always possible using inline functions, as shown by the following example:
...