RFC acceptable handling of VLAs across toolchains

Stephen Hemminger stephen at networkplumber.org
Wed Nov 8 03:31:14 CET 2023


On Tue, 7 Nov 2023 11:32:20 -0800
Tyler Retzlaff <roretzla at linux.microsoft.com> wrote:

> hi folks,
> 
> i'm seeking advice. we have use of VLAs which are now optional in
> standard C. some toolchains provide a conformant implementation and msvc
> does not (and never will).
> 
> we seem to have a few options, just curious about what people would
> prefer.
> 
> * use alloca
> 
> * use dynamically allocated storage
> 
> * conditional compiled code where the msvc leg uses one of the previous
>   two options
> 
> i'll leave it simple for now, i'd like to hear input rather than provide
> a recommendation for now.
>

VLAs are a bug magnet. Best to avoid them, most code doesn't need them.
The one common use case is code that accepts a burst of packets.
But such code could easily have an upper bound if necessary.

Please don't add more to the maze of #ifdef's 



More information about the dev mailing list