codebrainz/geany — comment on commit 682a0f1722d281197c8efb94d4186f938c1ba602
File: src/geany.h line 107
By b4n:

FUUU, where is my looong line note about this!?? Shitty GitHub.

Well, I'll be short this time then: never write function-style macros that don't require a semicolon after them. Use the `do { … } while (0)` structure (or `G_STMT_START { … } G_STMT_END` which expands to the same) so all calling code *needs* to add a semicolon after the call. This is particularly important here because it's conditional, so if one forgets the semicolon it might build with one GTK version but not another.

You could also use the `(if (cond) ? a : b)` construct which also needs a semicolon (and works if teh macro is supposed to return a value, which isn't the case here).

And one could complain about the `widget` arg being evaluated twice (although I doubt it'd be a real problem here); so either a local variable or a complete function (either static inline, or normal for not code duplication) mapped to the macro could also be a good candidate. Something like:

```C
void __GEANY_gtk_widget_set_can_default(GtkWidget *widget, gboolean can_default)
{
/* … */
}
#define gtk_widget_set_can_default __GEANY_gtk_widget_set_can_default
```