Skip to content

Replace variable length C-style arrays by std::vector

Variable length array is a C feature, available in C++ when compiler extensions are enabled. Newer versions of the clang compiler flag these issues as errors, such as the one below:

src/wifi/model/wifi-mac-queue-container.cc:212:20: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension]
  212 |     uint8_t buffer[size];
      |                    ^~~~
src/wifi/model/wifi-mac-queue-container.cc:212:20: note: initializer of 'size' is not a constant expression
src/wifi/model/wifi-mac-queue-container.cc:210:23: note: declared here
  210 |     const std::size_t size = tid.has_value() ? 8 : 7;
      |                       ^

This MR replaces variable length C-style arrays by std::vector. In some cases, C-style arrays can be kept, but its size has to be declared constexpr.

Edited by Gabriel Ferreira

Merge request reports