On Tue, 24 Feb 2026 at 06:29, Martin Uecker via Gcc <[email protected]> wrote:
>
> Am Montag, dem 23.02.2026 um 18:40 -0500 schrieb Yair Lenga:
> > Hi Martin,
> >
> > Yes - I believe something more "lightweight" than #pragma is needed.
> > What I've observed is that it's very "cumbersome", to write
> >
> > #pragma GCC diagnostic push
> > #pragma GCC diagnostic ignored "-Wvla"
> > double a[len] ;
> > #pragma GCC diagnostic push
> >
> > Technically, can be "compacted" via #define - but then it's becoming
> > something that it's not "C" any more: e .g.
> > int foo(int how_many) {
> > DECLARE_VLA(ddd, double, how_many) ; // Compact but NOT C
> > int x = 5 ;
> > }
Well that's a choice to define the macro so that it doesn't look like
a declaration.
Other ways to define it are possible, so that you have a proper
declaration present in the code:
#define NO_VLA_WARNING(...) \
_Pragma("GCC diagnostic push"); \
_Pragma("GCC diagnostic ignored \"-Wvla\""); \
__VA_ARGS__; \
_Pragma("GCC diagnostic pop");
int foo(int how_many) {
NO_VLA_WARNING( double ddd[how_many] );
int x = 5 ;
}