Skip to content

util: auto-declare the element variable in ARRAY_FOR_EACH

Peter Hutterer requested to merge whot/libinput:wip/array-for-each into main

All cases we have in our code base have an otherwise unused variable to loop through the array. Let's auto-declare this as part of the loop.

@JoseExposito - I'm a bit in two minds about this. It's not a bad idea per se but it seems to confuse the clangd LSP since whatever is part of elem isn't declared in its mind. The new use is just:

static void bar() {
  int array[6];
  ARRAY_FOR_EACH(array, foo) {
     *foo = 1;
  }
}

Merge request reports