3 ms·
Yes, which is why I would always use the second example for the print function. Edit: In fact it is possible to handle the cases explicitly while enforcing typ
by any1 9y ago
Yes, which is why I would always use the second example for the print function.
Edit: In fact it is possible to handle the cases explicitly while enforcing types by having the X-macros call functions in the switch/case and declaring prototypes via the macros:
#define X(type, ...) void printSettings_ ## name(type);
SETTINGS
#undef X
void printSettings(const Setting& s) {
switch(s.tag) {
#define X(type, name) \
case t_ ## type: printSettings_ ## name(s.name); break;
SETTINGS
#undef X
}
}
Then you define printSettings_... and have them do stuff with the data.