qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] CMSG_SPACE() causing compile time error on Mac OS X
@ 2016-01-17 22:23 Programmingkid
  2016-01-17 23:22 ` Paolo Bonzini
  2016-01-18  9:58 ` Daniel P. Berrange
  0 siblings, 2 replies; 15+ messages in thread
From: Programmingkid @ 2016-01-17 22:23 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel qemu-devel

I was wondering if you had problems compiling QEMU on Mac OS X recently. On my system, the channel-socket.c file causes this error:

io/channel-socket.c: In function 'qio_channel_socket_writev':
io/channel-socket.c:497:18: error: variable-sized object may not be initialized
     char control[CMSG_SPACE(sizeof(int) * SOCKET_MAX_FDS)] = { 0 };
  
As a test I made this simple program:

#include <sys/socket.h>
#include <stdio.h>

int main (int argc, char * const argv[]) {
    printf("GCC version = %d.%d.%d\n", __GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__);
    char control[CMSG_SPACE(sizeof(int) * 16)] = { 0 };
    control[0] = 'a';  // just to eliminate a warning
    return 0;
}

When compiling under Xcode, the program does compile and run. It prints "GCC version = 4.2.1".

When I try to compile it under gcc 4.2.1 using just the terminal, I see this error message:
main.cpp: In function ‘int main(int, char* const*)’:
main.cpp:6: error: size of array ‘control’ is not an integral constant-expression

Why there is a difference between XCode and the terminal I have no idea. 

When compiling it under gcc 4.9.2, it compiles and runs without problem. 

I have set the configure option for cc to gcc-4.9 with this "-cc=gcc-4.9". So the error message makes me believe that the wrong compiler is being used. 

This is the full configure command options I used:
./configure --cxx=gcc-4.9 --cc=gcc-4.9 --objcc=gcc-4.9 --disable-gtk --disable-sdl --target-list=ppc-softmmu,i386-softmmu

Any insight as to what could be wrong? 

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2016-01-19 23:49 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).