3 ms·
I'm not a fan of your suggested approach because automatic reformatting will remove the indentation, whether done in an editor or with a tool like clang-format,
by comex 7y ago
I'm not a fan of your suggested approach because automatic reformatting will remove the indentation, whether done in an editor or with a tool like clang-format, etc. To be fair, automatic reformatting does have its limitations, and there are some cases where it's best to just disable it, such as in the definitions of some macros. However, I prefer to avoid requiring users of my macros to turn it off, if possible.
In this case, I think you could make it work without any macro at the end, just a closing brace, without changing the rest of the syntax (including how the label-like constructs implicitly open a scope, which I think is a bad design but whatever). Something like this (for simplicity I've omitted backslashes and the concat calls needed to make label names unique):
#define choose
if (1)
goto register_options;
else
while (1)
if (1) {
/* We get here once the registrations are done */
void *target = mill_choose_wait_();
goto *target;
} else
register_options:
if (0) {
#define in(ch, type, var)
} else if (({goto register_N; did_register_N: 0;})) {
type var;
register_N:
mill_choose_in_(ch, &var, &&picked_N); /* computed goto because why not */
goto did_register_N;
picked_N