qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Paz Offer <poffer@nvidia.com>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>
Subject: Re: ISO C90 compilation error
Date: Thu, 29 Feb 2024 07:59:48 +0000	[thread overview]
Message-ID: <ZeA5ZbbHLy9mhmsa@redhat.com> (raw)
In-Reply-To: <MW4PR12MB6997B8D6225D08E8F3E2DE55A05F2@MW4PR12MB6997.namprd12.prod.outlook.com>

On Thu, Feb 29, 2024 at 07:03:35AM +0000, Paz Offer wrote:
> Hi,
> 
> I am trying to build my code with QEMU and getting compilation error according to the ISO C90 standard:
> 
>       const size_t buf_size = 31;
>       char buffer[buf_size + 1];
> 
>       error: ISO C90 forbids array ‘buffer’ whose size can’t be evaluated [-Werror=vla]
> 
> I noticed that the code builds with '-std=gnu11', which is newer then
> C90, so this is not clear to me why I get this error.
> Where is the correct place to specify the language version for this?

QEMU has set compiler flags to explicitly /forbid/ use of variable
sized arrays on the stack, as it is a known dangerous language
feature. You must refactor your changes to avoid this by using either
a statically sized array, or allocating on the heap.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  parent reply	other threads:[~2024-02-29  8:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-29  7:03 ISO C90 compilation error Paz Offer
2024-02-29  7:14 ` Thomas Huth
2024-02-29  7:59 ` Daniel P. Berrangé [this message]
2024-02-29  9:41   ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZeA5ZbbHLy9mhmsa@redhat.com \
    --to=berrange@redhat.com \
    --cc=poffer@nvidia.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).