qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Eric Blake <eblake@redhat.com>
Cc: Programmingkid <programmingkidx@gmail.com>,
	qemu-devel qemu-devel <qemu-devel@nongnu.org>,
	Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X
Date: Mon, 18 Jan 2016 17:59:13 +0000	[thread overview]
Message-ID: <CAFEAcA8DdM3woeYoCzSRJVwPQ249oQJ3x1-SmJfHzTT4zbfgqQ@mail.gmail.com> (raw)
In-Reply-To: <569D24D2.3000800@redhat.com>

On 18 January 2016 at 17:45, Eric Blake <eblake@redhat.com> wrote:
> On 01/17/2016 04:45 PM, Programmingkid wrote:
>>> What's the definition of the CMSG_SPACE macro under OS X?
>>>
>>> Paolo
>>
>> #define       CMSG_SPACE(l)           (__DARWIN_ALIGN32(sizeof(struct cmsghdr)) + __DARWIN_ALIGN32(l))
>
> And the definition of __DARWIN_ALIGN32()?
>
> It looks like the definition is not properly resulting in a compile-time
> constant, and therefore the warning about the initializer is resulting
> because you can't initialize a dynamically-sized array.  But you still
> haven't shown us why the headers are resulting in a non-constant size.

FWIW, on my OSX system (OSX 10.10.5, Xcode 7.1), compiling the test
program with

  gcc -Wall -E  -o /tmp/varray.S /tmp/varray.c

shows that the array definition expands to

    char control[(((__darwin_size_t)((char
*)(__darwin_size_t)(sizeof(struct cmsghdr)) + (sizeof(__uint32_t) -
1)) &~ (sizeof(__uint32_t) - 1)) + ((__darwin_size_t)((char
*)(__darwin_size_t)(sizeof(int) * 16) + (sizeof(__uint32_t) - 1)) &~
(sizeof(__uint32_t) - 1)))] = { 0 };

the relevant macro definitions being
#define __DARWIN_ALIGNBYTES     (sizeof(__darwin_size_t) - 1)
#define       __DARWIN_ALIGN32(p)       ((__darwin_size_t)((char
*)(__darwin_size_t)(p) + __DARWIN_ALIGNBYTES32) &~
__DARWIN_ALIGNBYTES32)


this is with a 'gcc' that gcc --version reports as
Configured with:
--prefix=/Applications/Xcode.app/Contents/Developer/usr
--with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.0 (clang-700.1.76)
Target: x86_64-apple-darwin14.5.0
Thread model: posix

and which claims itself to be 4.2.1 by the printout from the test
program (ie it's clang under the hood).

I don't get any compiler warnings from
  gcc -Wall -O2  -o /tmp/varray /tmp/varray.c

I don't know what the difference between my setup and John's is
(likely an older clang version).

thanks
-- PMM

  reply	other threads:[~2016-01-18 17:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-17 22:23 [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X Programmingkid
2016-01-17 23:22 ` Paolo Bonzini
2016-01-17 23:45   ` Programmingkid
2016-01-18 17:45     ` Eric Blake
2016-01-18 17:59       ` Peter Maydell [this message]
2016-01-18 19:46         ` Programmingkid
2016-01-18 19:50       ` Programmingkid
2016-01-18 20:49         ` Peter Maydell
2016-01-18 21:09           ` Programmingkid
2016-01-18 22:09             ` Peter Maydell
2016-01-19  1:23               ` Programmingkid
2016-01-19 23:49                 ` Programmingkid
2016-01-18  9:58 ` Daniel P. Berrange
2016-01-18 14:36   ` Programmingkid
2016-01-19 14:06     ` Daniel P. Berrange

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=CAFEAcA8DdM3woeYoCzSRJVwPQ249oQJ3x1-SmJfHzTT4zbfgqQ@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=eblake@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=programmingkidx@gmail.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).