One dead give-away of a GNOME/Gtk programmer is how they format their headers. For the better part of two decades, many of us have been trying to keep things aligned. Whether this is cargo-culted or of real benefit depends on the reader. Generally, I find them easier to filter through.
Unfortunately, none of
uncrustify have managed to exactly represent our style which makes automated code formatting tools rather problematic. Especially in an automated fashion.
For example, notice how the types and trailing asterisks, stay aligned, in multiple directions.
FOO_EXPORT void foo_do_something_async (Foo *self, const gchar * const *params, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); FOO_EXPORT Bar *foo_do_something_finish (Foo *self, GAsyncResult *result, GError **error);
Keeping that sort of code aligned is quite a pain. Even for vim users who can fairly easily repeat commands. Worse, it can explode patches into unreadable messiness.
Anyway, I added a new command in Builder last night that will format these in this style so long as you don’t do anything to trip it up. Just select a block of function declarations, and run
format-decls from the command bar.
It doesn’t yet handle vtable entries, but that shouldn’t be too painful. Also, it doesn’t handle miscellaneous other C code in-between declarations (except
Christian Hergert: Keeping those headers aligned
Source: Planet Gnome