Force the C standard to gnu99
v3 cover Force the C standard to gnu99
Different versions of GCC and Clang use different versions of the C standard by default. To avoid compilation problems with different compilers in the future, we should enforce one language level for all compilers. Since "gnu99" is the only usable option right now (later versions are still marked as experimental in GCC v4.8), we enforce compiling with -std=gnu99 now (in the second patch). This caused some new warnings/erros to appear with clang, which are fixed by the first patch now.
Thomas Huth (2):
include/hw/ppc: Fix compilation with clang -std=gnu99
configure: Force the C standard to gnu99
configure | 5 ++++- include/hw/ppc/spapr.h | 4 ++-- include/hw/ppc/spapr_xive.h | 2 +- include/hw/ppc/xics.h | 4 ++-- 4 files changed, 9 insertions(+), 6 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v3 1/2 include/hw/ppc: Fix compilation with clang -std=gnu99
When compiling with Clang and -std=gnu99, I get the following errors:
CC ppc64-softmmu/hw/intc/xics_spapr.o
In file included from hw/intc/xics_spapr.c:34:include/hw/ppc/xics.h:46:25: error: redefinition of typedef 'ICSState' is a C11 feature
[-Werror,-Wtypedef-redefinition]
typedef struct ICSState ICSState;
^
include/hw/ppc/spapr.h:18:25: note: previous definition is here
typedef struct ICSState ICSState;
^
In file included from hw/intc/xics_spapr.c:34:
include/hw/ppc/xics.h:203:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature
[-Werror,-Wtypedef-redefinition]
typedef struct sPAPRMachineState sPAPRMachineState;
^
include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here
typedef struct sPAPRMachineState sPAPRMachineState;
^ CC ppc64-softmmu/hw/intc/spapr_xive.o
In file included from hw/intc/spapr_xive.c:19:include/hw/ppc/spapr_xive.h:38:3: error: redefinition of typedef 'sPAPRXive' is a C11 feature
[-Werror,-Wtypedef-redefinition]
} sPAPRXive;
^include/hw/ppc/spapr.h:20:26: note: previous definition is here
typedef struct sPAPRXive sPAPRXive;
^
In file included from hw/intc/spapr_xive.c:19:
include/hw/ppc/spapr_xive.h:45:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature
[-Werror,-Wtypedef-redefinition]
typedef struct sPAPRMachineState sPAPRMachineState;
^
include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here
typedef struct sPAPRMachineState sPAPRMachineState;
^ CC ppc64-softmmu/hw/char/spapr_vty.o
In file included from hw/char/spapr_vty.c:8:
In file included from include/hw/ppc/spapr.h:12:include/hw/ppc/spapr_xive.h:45:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature
[-Werror,-Wtypedef-redefinition]
typedef struct sPAPRMachineState sPAPRMachineState;
^
include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here
typedef struct sPAPRMachineState sPAPRMachineState;
^Since we're going to make -std=gnu99 mandatory, fix these issues by including the right header files indead of typedeffing stuff twice.
--- include/hw/ppc/spapr.h | 4 ++-- include/hw/ppc/spapr_xive.h | 2 +- include/hw/ppc/xics.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)
include/hw/ppc/spapr.h +2 -2
@@ -8,6 +8,8 @@#include "hw/mem/pc-dimm.h" #include "hw/ppc/spapr_ovec.h" #include "hw/ppc/spapr_irq.h" +#include "hw/ppc/xics.h" +#include "hw/ppc/spapr_xive.h" struct VIOsPAPRBus ;struct sPAPRPHBState ;
@@ -15,8 +17,6 @@ struct sPAPRNVRAM;typedef struct sPAPREventLogEntry sPAPREventLogEntry ;typedef struct sPAPREventSource sPAPREventSource ;typedef struct sPAPRPendingHPT sPAPRPendingHPT ; -typedef struct ICSState ICSState ; -typedef struct sPAPRXive sPAPRXive ;#define HPTE64_V_HPTE_DIRTY 0x0000000000000040ULL#define SPAPR_ENTRY_POINT 0x100
include/hw/ppc/spapr_xive.h +1 -1
@@ -42,7 +42,7 @@ bool spapr_xive_irq_free(sPAPRXive *xive, uint32_t lisn);void spapr_xive_pic_print_info (sPAPRXive *xive,Monitor *mon);qemu_irq spapr_xive_qirq (sPAPRXive *xive,uint32_t lisn); -typedef struct sPAPRMachineState sPAPRMachineState ; +#include "hw/ppc/spapr.h" /* for sPAPRMachineState */ void spapr_xive_hcall_init (sPAPRMachineState *spapr); void spapr_dt_xive(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt,
include/hw/ppc/xics.h +2 -2
@@ -47,6 +47,8 @@ typedef struct ICSState ICSState;typedef struct ICSIRQState ICSIRQState ;typedef struct XICSFabric XICSFabric ; +#include "hw/ppc/spapr.h" +#define TYPE_ICP "icp"#define ICP (obj) OBJECT_CHECK(ICPState, (obj), TYPE_ICP)
@@ -200,8 +202,6 @@ void ics_pic_print_info(ICSState *ics, Monitor *mon);void ics_resend (ICSState *ics);void icp_resend (ICPState *ss); -typedef struct sPAPRMachineState sPAPRMachineState ; -void spapr_dt_xics (sPAPRMachineState *spapr,uint32_t nr_servers,void *fdt,uint32_t phandle);int xics_kvm_init (sPAPRMachineState *spapr,Error **errp);
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/2] include/hw/ppc: Fix compilation with clang -std=gnu99
Quoted 84 lines · Thomas Huth
When compiling with Clang and -std=gnu99, I get the following errors:
CC
ppc64-softmmu/hw/intc/xics_spapr.o
In file included fromhw/intc/xics_spapr.c:34:include/hw/ppc/xics.h:46:25: error: redefinition of typedef 'ICSState' is a C11 feature
[-Werror,-Wtypedef-redefinition]typedef struct ICSState ICSState; ^ include/hw/ppc/spapr.h:18:25: note: previous definition is here typedef struct ICSState ICSState; ^ In file included from hw/intc/xics_spapr.c:34: include/hw/ppc/xics.h:203:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature [-Werror,-Wtypedef-redefinition] typedef struct sPAPRMachineState sPAPRMachineState; ^ include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here typedef struct sPAPRMachineState sPAPRMachineState; ^CC
ppc64-softmmu/hw/intc/spapr_xive.o
In file included fromhw/intc/spapr_xive.c:19:include/hw/ppc/spapr_xive.h:38:3: error: redefinition of typedef 'sPAPRXive' is a C11 feature
[-Werror,-Wtypedef-redefinition]
} sPAPRXive;
^include/hw/ppc/spapr.h:20:26: note: previous definition is heretypedef struct sPAPRXive sPAPRXive; ^ In file included from hw/intc/spapr_xive.c:19: include/hw/ppc/spapr_xive.h:45:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature [-Werror,-Wtypedef-redefinition] typedef struct sPAPRMachineState sPAPRMachineState; ^ include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here typedef struct sPAPRMachineState sPAPRMachineState; ^CC
ppc64-softmmu/hw/char/spapr_vty.o
In file included fromhw/char/spapr_vty.c:8:
In file included frominclude/hw/ppc/spapr.h:12:include/hw/ppc/spapr_xive.h:45:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature
[-Werror,-Wtypedef-redefinition]typedef struct sPAPRMachineState sPAPRMachineState; ^ include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here typedef struct sPAPRMachineState sPAPRMachineState; ^Since we're going to make -std=gnu99 mandatory, fix these issues by including the right header files indead of typedeffing stuff twice.
Signed-off-by Thomas Huth <[email protected]>--- include/hw/ppc/spapr.h | 4 ++-- include/hw/ppc/spapr_xive.h | 2 +- include/hw/ppc/xics.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)include/hw/ppc/spapr.h +2
-2@@ -8,6 +8,8 @@#include "hw/mem/pc-dimm.h" #include "hw/ppc/spapr_ovec.h" #include "hw/ppc/spapr_irq.h" +#include "hw/ppc/xics.h" +#include "hw/ppc/spapr_xive.h" struct VIOsPAPRBus ;struct sPAPRPHBState ;@@ -15,8 +17,6 @@ struct sPAPRNVRAM;typedef struct sPAPREventLogEntry sPAPREventLogEntry ;typedef struct sPAPREventSource sPAPREventSource ;typedef struct sPAPRPendingHPT sPAPRPendingHPT ; -typedef struct ICSState ICSState ; -typedef struct sPAPRXive sPAPRXive ;#define HPTE64_V_HPTE_DIRTY 0x0000000000000040ULL#define SPAPR_ENTRY_POINT 0x100include/hw/ppc/spapr_xive.h +0
-0
include/hw/ppc/spapr_xive.h bool spapr_xive_irq_free(sPAPRXive *xive, uint32_t lisn); · line 45
Quoted 5 lines
include/hw/ppc/spapr_xive.h +1
-1@@ -42,7 +42,7 @@ bool spapr_xive_irq_free(sPAPRXive *xive, uint32_t lisn);void spapr_xive_pic_print_info (sPAPRXive *xive,Monitor *mon);qemu_irq spapr_xive_qirq (sPAPRXive *xive,uint32_t lisn); -typedef struct sPAPRMachineState sPAPRMachineState ; +#include "hw/ppc/spapr.h" /* for sPAPRMachineState */
so both files include each other, how nice ...
include/hw/ppc/xics.h typedef struct ICSState ICSState; · line 51
Quoted 12 lines
include/hw/ppc/spapr_xive.h +0
-0void spapr_xive_hcall_init (sPAPRMachineState *spapr); void spapr_dt_xive(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt,include/hw/ppc/xics.h +2
-0@@ -47,6 +47,8 @@ typedef struct ICSState ICSState;typedef struct ICSIRQState ICSIRQState ;typedef struct XICSFabric XICSFabric ; +#include "hw/ppc/spapr.h" +
and again ... I *really really* prefer forward declarations.
Grumbles,
C.
Quoted 13 lines
include/hw/ppc/xics.h +0
-2#define TYPE_ICP "icp"#define ICP (obj) OBJECT_CHECK(ICPState, (obj), TYPE_ICP)@@ -200,8 +202,6 @@ void ics_pic_print_info(ICSState *ics, Monitor *mon);void ics_resend (ICSState *ics);void icp_resend (ICPState *ss); -typedef struct sPAPRMachineState sPAPRMachineState ; -void spapr_dt_xics (sPAPRMachineState *spapr,uint32_t nr_servers,void *fdt,uint32_t phandle);int xics_kvm_init (sPAPRMachineState *spapr,Error **errp);
Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/2] include/hw/ppc: Fix compilation with clang -std=gnu99
Quoted 88 lines · Cédric Le Goater
Quoted 87 lines · Thomas Huth
When compiling with Clang and -std=gnu99, I get the following errors:
CC
ppc64-softmmu/hw/intc/xics_spapr.o
In file included fromhw/intc/xics_spapr.c:34:include/hw/ppc/xics.h:46:25: error: redefinition of typedef 'ICSState' is a C11 feature
[-Werror,-Wtypedef-redefinition]typedef struct ICSState ICSState; ^ include/hw/ppc/spapr.h:18:25: note: previous definition is here typedef struct ICSState ICSState; ^ In file included from hw/intc/xics_spapr.c:34: include/hw/ppc/xics.h:203:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature [-Werror,-Wtypedef-redefinition] typedef struct sPAPRMachineState sPAPRMachineState; ^ include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here typedef struct sPAPRMachineState sPAPRMachineState; ^CC
ppc64-softmmu/hw/intc/spapr_xive.o
In file included fromhw/intc/spapr_xive.c:19:include/hw/ppc/spapr_xive.h:38:3: error: redefinition of typedef 'sPAPRXive' is a C11 feature
[-Werror,-Wtypedef-redefinition]
} sPAPRXive;
^include/hw/ppc/spapr.h:20:26: note: previous definition is heretypedef struct sPAPRXive sPAPRXive; ^ In file included from hw/intc/spapr_xive.c:19: include/hw/ppc/spapr_xive.h:45:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature [-Werror,-Wtypedef-redefinition] typedef struct sPAPRMachineState sPAPRMachineState; ^ include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here typedef struct sPAPRMachineState sPAPRMachineState; ^CC
ppc64-softmmu/hw/char/spapr_vty.o
In file included fromhw/char/spapr_vty.c:8:
In file included frominclude/hw/ppc/spapr.h:12:include/hw/ppc/spapr_xive.h:45:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature
[-Werror,-Wtypedef-redefinition]typedef struct sPAPRMachineState sPAPRMachineState; ^ include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here typedef struct sPAPRMachineState sPAPRMachineState; ^Since we're going to make -std=gnu99 mandatory, fix these issues by including the right header files indead of typedeffing stuff twice.
Signed-off-by Thomas Huth <[email protected]>--- include/hw/ppc/spapr.h | 4 ++-- include/hw/ppc/spapr_xive.h | 2 +- include/hw/ppc/xics.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)include/hw/ppc/spapr.h +2
-2@@ -8,6 +8,8 @@#include "hw/mem/pc-dimm.h" #include "hw/ppc/spapr_ovec.h" #include "hw/ppc/spapr_irq.h" +#include "hw/ppc/xics.h" +#include "hw/ppc/spapr_xive.h" struct VIOsPAPRBus ;struct sPAPRPHBState ;@@ -15,8 +17,6 @@ struct sPAPRNVRAM;typedef struct sPAPREventLogEntry sPAPREventLogEntry ;typedef struct sPAPREventSource sPAPREventSource ;typedef struct sPAPRPendingHPT sPAPRPendingHPT ; -typedef struct ICSState ICSState ; -typedef struct sPAPRXive sPAPRXive ;#define HPTE64_V_HPTE_DIRTY 0x0000000000000040ULL#define SPAPR_ENTRY_POINT 0x100include/hw/ppc/spapr_xive.h +0
-0@@ -42,7 +42,7 @@ bool spapr_xive_irq_free(sPAPRXive *xive, uint32_t lisn);void spapr_xive_pic_print_info (sPAPRXive *xive,Monitor *mon);qemu_irq spapr_xive_qirq (sPAPRXive *xive,uint32_t lisn);
Quoted 4 lines
include/hw/ppc/spapr_xive.h bool spapr_xive_irq_free(sPAPRXive *xive, uint32_t lisn); · line 45
Quoted 2 lines
include/hw/ppc/spapr_xive.h +1
-1-typedef struct sPAPRMachineState sPAPRMachineState ; +#include "hw/ppc/spapr.h" /* for sPAPRMachineState */ so both files include each other, how nice ...
If the header files are mutually dependent it makes me wonder what the point of having them split up is ?
Feels like either they need to be merged, or they need to be split up and refactored even more to remove the mutual dependancy.
Regards,
Daniel
Signature · 3 lines
|: 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 :|
Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/2] include/hw/ppc: Fix compilation with clang -std=gnu99
Quoted 89 lines · Daniel P. Berrangé
Quoted 88 lines · Cédric Le Goater
Quoted 87 lines · Thomas Huth
When compiling with Clang and -std=gnu99, I get the following errors:
CC
ppc64-softmmu/hw/intc/xics_spapr.o
In file included fromhw/intc/xics_spapr.c:34:include/hw/ppc/xics.h:46:25: error: redefinition of typedef 'ICSState' is a C11 feature
[-Werror,-Wtypedef-redefinition]typedef struct ICSState ICSState; ^ include/hw/ppc/spapr.h:18:25: note: previous definition is here typedef struct ICSState ICSState; ^ In file included from hw/intc/xics_spapr.c:34: include/hw/ppc/xics.h:203:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature [-Werror,-Wtypedef-redefinition] typedef struct sPAPRMachineState sPAPRMachineState; ^ include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here typedef struct sPAPRMachineState sPAPRMachineState; ^CC
ppc64-softmmu/hw/intc/spapr_xive.o
In file included fromhw/intc/spapr_xive.c:19:include/hw/ppc/spapr_xive.h:38:3: error: redefinition of typedef 'sPAPRXive' is a C11 feature
[-Werror,-Wtypedef-redefinition]
} sPAPRXive;
^include/hw/ppc/spapr.h:20:26: note: previous definition is heretypedef struct sPAPRXive sPAPRXive; ^ In file included from hw/intc/spapr_xive.c:19: include/hw/ppc/spapr_xive.h:45:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature [-Werror,-Wtypedef-redefinition] typedef struct sPAPRMachineState sPAPRMachineState; ^ include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here typedef struct sPAPRMachineState sPAPRMachineState; ^CC
ppc64-softmmu/hw/char/spapr_vty.o
In file included fromhw/char/spapr_vty.c:8:
In file included frominclude/hw/ppc/spapr.h:12:include/hw/ppc/spapr_xive.h:45:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature
[-Werror,-Wtypedef-redefinition]typedef struct sPAPRMachineState sPAPRMachineState; ^ include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here typedef struct sPAPRMachineState sPAPRMachineState; ^Since we're going to make -std=gnu99 mandatory, fix these issues by including the right header files indead of typedeffing stuff twice.
Signed-off-by Thomas Huth <[email protected]>--- include/hw/ppc/spapr.h | 4 ++-- include/hw/ppc/spapr_xive.h | 2 +- include/hw/ppc/xics.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)include/hw/ppc/spapr.h +2
-2@@ -8,6 +8,8 @@#include "hw/mem/pc-dimm.h" #include "hw/ppc/spapr_ovec.h" #include "hw/ppc/spapr_irq.h" +#include "hw/ppc/xics.h" +#include "hw/ppc/spapr_xive.h" struct VIOsPAPRBus ;struct sPAPRPHBState ;@@ -15,8 +17,6 @@ struct sPAPRNVRAM;typedef struct sPAPREventLogEntry sPAPREventLogEntry ;typedef struct sPAPREventSource sPAPREventSource ;typedef struct sPAPRPendingHPT sPAPRPendingHPT ; -typedef struct ICSState ICSState ; -typedef struct sPAPRXive sPAPRXive ;#define HPTE64_V_HPTE_DIRTY 0x0000000000000040ULL#define SPAPR_ENTRY_POINT 0x100include/hw/ppc/spapr_xive.h +0
-0@@ -42,7 +42,7 @@ bool spapr_xive_irq_free(sPAPRXive *xive, uint32_t lisn);void spapr_xive_pic_print_info (sPAPRXive *xive,Monitor *mon);qemu_irq spapr_xive_qirq (sPAPRXive *xive,uint32_t lisn);
Quoted 7 lines
Quoted 4 lines
include/hw/ppc/spapr_xive.h bool spapr_xive_irq_free(sPAPRXive *xive, uint32_t lisn); · line 45
Quoted 2 lines
include/hw/ppc/spapr_xive.h +1
-1-typedef struct sPAPRMachineState sPAPRMachineState ; +#include "hw/ppc/spapr.h" /* for sPAPRMachineState */ so both files include each other, how nice ...
If the header files are mutually dependent it makes me wonder what the point of having them split up is ?
The XICS interrupt controller models are used in two different machines, sPAPR and PowerNV.
Quoted 2 lines
Feels like either they need to be merged, or they need to be split up and refactored even more to remove the mutual dependancy.
yes or that some spapr_* definitions do not belong to the common xics.h file.
Thanks,
C.
Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/2] include/hw/ppc: Fix compilation with clang -std=gnu99
Quoted 98 lines · On Wed, 9 Jan 2019 18:40:48 +0100 Cédric Le Goater <[email protected]> wrote:
Quoted 89 lines · Daniel P. Berrangé
Quoted 88 lines · Cédric Le Goater
Quoted 87 lines · Thomas Huth
When compiling with Clang and -std=gnu99, I get the following errors:
CC
ppc64-softmmu/hw/intc/xics_spapr.o
In file included fromhw/intc/xics_spapr.c:34:include/hw/ppc/xics.h:46:25: error: redefinition of typedef 'ICSState' is a C11 feature
[-Werror,-Wtypedef-redefinition]typedef struct ICSState ICSState; ^ include/hw/ppc/spapr.h:18:25: note: previous definition is here typedef struct ICSState ICSState; ^ In file included from hw/intc/xics_spapr.c:34: include/hw/ppc/xics.h:203:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature [-Werror,-Wtypedef-redefinition] typedef struct sPAPRMachineState sPAPRMachineState; ^ include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here typedef struct sPAPRMachineState sPAPRMachineState; ^CC
ppc64-softmmu/hw/intc/spapr_xive.o
In file included fromhw/intc/spapr_xive.c:19:include/hw/ppc/spapr_xive.h:38:3: error: redefinition of typedef 'sPAPRXive' is a C11 feature
[-Werror,-Wtypedef-redefinition]
} sPAPRXive;
^include/hw/ppc/spapr.h:20:26: note: previous definition is heretypedef struct sPAPRXive sPAPRXive; ^ In file included from hw/intc/spapr_xive.c:19: include/hw/ppc/spapr_xive.h:45:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature [-Werror,-Wtypedef-redefinition] typedef struct sPAPRMachineState sPAPRMachineState; ^ include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here typedef struct sPAPRMachineState sPAPRMachineState; ^CC
ppc64-softmmu/hw/char/spapr_vty.o
In file included fromhw/char/spapr_vty.c:8:
In file included frominclude/hw/ppc/spapr.h:12:include/hw/ppc/spapr_xive.h:45:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature
[-Werror,-Wtypedef-redefinition]typedef struct sPAPRMachineState sPAPRMachineState; ^ include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here typedef struct sPAPRMachineState sPAPRMachineState; ^Since we're going to make -std=gnu99 mandatory, fix these issues by including the right header files indead of typedeffing stuff twice.
Signed-off-by Thomas Huth <[email protected]>--- include/hw/ppc/spapr.h | 4 ++-- include/hw/ppc/spapr_xive.h | 2 +- include/hw/ppc/xics.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)include/hw/ppc/spapr.h +2
-2@@ -8,6 +8,8 @@#include "hw/mem/pc-dimm.h" #include "hw/ppc/spapr_ovec.h" #include "hw/ppc/spapr_irq.h" +#include "hw/ppc/xics.h" +#include "hw/ppc/spapr_xive.h" struct VIOsPAPRBus ;struct sPAPRPHBState ;@@ -15,8 +17,6 @@ struct sPAPRNVRAM;typedef struct sPAPREventLogEntry sPAPREventLogEntry ;typedef struct sPAPREventSource sPAPREventSource ;typedef struct sPAPRPendingHPT sPAPRPendingHPT ; -typedef struct ICSState ICSState ; -typedef struct sPAPRXive sPAPRXive ;#define HPTE64_V_HPTE_DIRTY 0x0000000000000040ULL#define SPAPR_ENTRY_POINT 0x100include/hw/ppc/spapr_xive.h +0
-0@@ -42,7 +42,7 @@ bool spapr_xive_irq_free(sPAPRXive *xive, uint32_t lisn);void spapr_xive_pic_print_info (sPAPRXive *xive,Monitor *mon);qemu_irq spapr_xive_qirq (sPAPRXive *xive,uint32_t lisn);Quoted 7 lines
Quoted 4 lines
include/hw/ppc/spapr_xive.h bool spapr_xive_irq_free(sPAPRXive *xive, uint32_t lisn); · line 45
Quoted 2 lines
include/hw/ppc/spapr_xive.h +1
-1-typedef struct sPAPRMachineState sPAPRMachineState ; +#include "hw/ppc/spapr.h" /* for sPAPRMachineState */ so both files include each other, how nice ...
If the header files are mutually dependent it makes me wonder what the point of having them split up is ?
Quoted 8 lines
The XICS interrupt controller models are used in two different machines, sPAPR and PowerNV.
Quoted 2 lines
Feels like either they need to be merged, or they need to be split up and refactored even more to remove the mutual dependancy.
yes or that some spapr_* definitions do not belong to the common
xics.hfile.
Yeah,
These should move to a new xics_spapr.h or maybe even spapr.h for simplicity:
void spapr_dt_xics(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt,
uint32_t phandle);
int xics_kvm_init(sPAPRMachineState *spapr, Error **errp); void xics_spapr_init(sPAPRMachineState *spapr);
Quoted 5 lines
Thanks,
C.
Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/2] include/hw/ppc: Fix compilation with clang -std=gnu99
Quoted 110 lines · Greg Kurz
Quoted 98 lines · On Wed, 9 Jan 2019 18:40:48 +0100 Cédric Le Goater <[email protected]> wrote:
Quoted 89 lines · Daniel P. Berrangé
Quoted 88 lines · Cédric Le Goater
Quoted 87 lines · Thomas Huth
When compiling with Clang and -std=gnu99, I get the following errors:
CC
ppc64-softmmu/hw/intc/xics_spapr.o
In file included fromhw/intc/xics_spapr.c:34:include/hw/ppc/xics.h:46:25: error: redefinition of typedef 'ICSState' is a C11 feature
[-Werror,-Wtypedef-redefinition]typedef struct ICSState ICSState; ^ include/hw/ppc/spapr.h:18:25: note: previous definition is here typedef struct ICSState ICSState; ^ In file included from hw/intc/xics_spapr.c:34: include/hw/ppc/xics.h:203:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature [-Werror,-Wtypedef-redefinition] typedef struct sPAPRMachineState sPAPRMachineState; ^ include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here typedef struct sPAPRMachineState sPAPRMachineState; ^CC
ppc64-softmmu/hw/intc/spapr_xive.o
In file included fromhw/intc/spapr_xive.c:19:include/hw/ppc/spapr_xive.h:38:3: error: redefinition of typedef 'sPAPRXive' is a C11 feature
[-Werror,-Wtypedef-redefinition]
} sPAPRXive;
^include/hw/ppc/spapr.h:20:26: note: previous definition is heretypedef struct sPAPRXive sPAPRXive; ^ In file included from hw/intc/spapr_xive.c:19: include/hw/ppc/spapr_xive.h:45:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature [-Werror,-Wtypedef-redefinition] typedef struct sPAPRMachineState sPAPRMachineState; ^ include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here typedef struct sPAPRMachineState sPAPRMachineState; ^CC
ppc64-softmmu/hw/char/spapr_vty.o
In file included fromhw/char/spapr_vty.c:8:
In file included frominclude/hw/ppc/spapr.h:12:include/hw/ppc/spapr_xive.h:45:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature
[-Werror,-Wtypedef-redefinition]typedef struct sPAPRMachineState sPAPRMachineState; ^ include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here typedef struct sPAPRMachineState sPAPRMachineState; ^Since we're going to make -std=gnu99 mandatory, fix these issues by including the right header files indead of typedeffing stuff twice.
Signed-off-by Thomas Huth <[email protected]>--- include/hw/ppc/spapr.h | 4 ++-- include/hw/ppc/spapr_xive.h | 2 +- include/hw/ppc/xics.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)include/hw/ppc/spapr.h +2
-2@@ -8,6 +8,8 @@#include "hw/mem/pc-dimm.h" #include "hw/ppc/spapr_ovec.h" #include "hw/ppc/spapr_irq.h" +#include "hw/ppc/xics.h" +#include "hw/ppc/spapr_xive.h" struct VIOsPAPRBus ;struct sPAPRPHBState ;@@ -15,8 +17,6 @@ struct sPAPRNVRAM;typedef struct sPAPREventLogEntry sPAPREventLogEntry ;typedef struct sPAPREventSource sPAPREventSource ;typedef struct sPAPRPendingHPT sPAPRPendingHPT ; -typedef struct ICSState ICSState ; -typedef struct sPAPRXive sPAPRXive ;#define HPTE64_V_HPTE_DIRTY 0x0000000000000040ULL#define SPAPR_ENTRY_POINT 0x100include/hw/ppc/spapr_xive.h +0
-0@@ -42,7 +42,7 @@ bool spapr_xive_irq_free(sPAPRXive *xive, uint32_t lisn);void spapr_xive_pic_print_info (sPAPRXive *xive,Monitor *mon);qemu_irq spapr_xive_qirq (sPAPRXive *xive,uint32_t lisn);Quoted 7 lines
Quoted 4 lines
include/hw/ppc/spapr_xive.h bool spapr_xive_irq_free(sPAPRXive *xive, uint32_t lisn); · line 45
Quoted 2 lines
include/hw/ppc/spapr_xive.h +1
-1-typedef struct sPAPRMachineState sPAPRMachineState ; +#include "hw/ppc/spapr.h" /* for sPAPRMachineState */ so both files include each other, how nice ...
If the header files are mutually dependent it makes me wonder what the point of having them split up is ?
Quoted 8 lines
The XICS interrupt controller models are used in two different machines, sPAPR and PowerNV.
Quoted 2 lines
Feels like either they need to be merged, or they need to be split up and refactored even more to remove the mutual dependancy.
yes or that some spapr_* definitions do not belong to the common
xics.hfile.
Quoted 8 lines
Yeah,
These should move to a new
xics_spapr.hor maybe evenspapr.hfor simplicity:void spapr_dt_xics(sPAPRMachineState *spapr,
uint32_tnr_servers, void *fdt,uint32_t phandle);int
xics_kvm_init(sPAPRMachineState *spapr, Error **errp); voidxics_spapr_init(sPAPRMachineState *spapr);
Ok, I'll move them to xics_spapr.h.
Thomas
Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/2] include/hw/ppc: Fix compilation with clang -std=gnu99
In reply to Daniel P. BerrangéQuoted 6 lines · Daniel P. Berrangé
Quoted 1 line
so both files include each other, how nice ...
If the header files are mutually dependent it makes me wonder what the point of having them split up is ?
Feels like either they need to be merged, or they need to be split up and refactored even more to remove the mutual dependancy.
If they include each other only for the typedefs, then prehaps the solution is to change the coding style and allow using struct in function prototypes. I'm pretty sure there are several examples of this already.
Paolo
Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/2] include/hw/ppc: Fix compilation with clang -std=gnu99
Quoted 5 lines · Paolo Bonzini
Quoted 4 lines · Daniel P. Berrangé
Quoted 1 line
so both files include each other, how nice ...
If the header files are mutually dependent it makes me wonder what the point of having them split up is ?
Quoted 7 lines
Quoted 2 lines
Feels like either they need to be merged, or they need to be split up and refactored even more to remove the mutual dependancy.
If they include each other only for the typedefs, then prehaps the solution is to change the coding style and allow using struct in function prototypes. I'm pretty sure there are several examples of this already.
Or stick the typedef in <typedefs.h>, instead of trying to find (or create) some other common header.
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/2] include/hw/ppc: Fix compilation with clang -std=gnu99
Quoted 9 lines · Eric Blake
Quoted 8 lines · Paolo Bonzini
Quoted 6 lines · Daniel P. Berrangé
Quoted 1 line
so both files include each other, how nice ...
If the header files are mutually dependent it makes me wonder what the point of having them split up is ?
Feels like either they need to be merged, or they need to be split up and refactored even more to remove the mutual dependancy.
Quoted 7 lines
Quoted 4 lines
If they include each other only for the typedefs, then prehaps the solution is to change the coding style and allow using struct in function prototypes. I'm pretty sure there are several examples of this already.
Or stick the typedef in <
typedefs.h>, instead of trying to find (or create) some other common header.
Putting typedefs for a very specific machine or device in typedefs.h doesn't seem too clean. Usually typedefs.h is used when things are shared by different subsystems (e.g. accelerator and device emulation, or frontend and backend), and I'm pretty sure that it could be made even smaller if someone was inclined to try.
Paolo
Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/2] include/hw/ppc: Fix compilation with clang -std=gnu99
In reply to Eric BlakeQuoted 9 lines · Eric Blake
Quoted 8 lines · Paolo Bonzini
Quoted 6 lines · Daniel P. Berrangé
Quoted 1 line
so both files include each other, how nice ...
If the header files are mutually dependent it makes me wonder what the point of having them split up is ?
Feels like either they need to be merged, or they need to be split up and refactored even more to remove the mutual dependancy.
Quoted 7 lines
Quoted 4 lines
If they include each other only for the typedefs, then prehaps the solution is to change the coding style and allow using struct in function prototypes. I'm pretty sure there are several examples of this already.
Or stick the typedef in <
typedefs.h>, instead of trying to find (or create) some other common header.
Probably better to just have a local spapr_types.h instead of polluting the global namespace.
Regards,
Daniel
Signature · 3 lines
|: 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 :|
Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/2] include/hw/ppc: Fix compilation with clang -std=gnu99
Quoted 15 lines · On Thu, 10 Jan 2019 10:12:43 +0000 Daniel P. Berrangé <[email protected]>…
Quoted 14 lines · Eric Blake
Quoted 12 lines · Paolo Bonzini
Quoted 6 lines · Daniel P. Berrangé
Quoted 1 line
so both files include each other, how nice ...
If the header files are mutually dependent it makes me wonder what the point of having them split up is ?
Feels like either they need to be merged, or they need to be split up and refactored even more to remove the mutual dependancy.
If they include each other only for the typedefs, then prehaps the solution is to change the coding style and allow using struct in function prototypes. I'm pretty sure there are several examples of this already.
Quoted 6 lines
Quoted 2 lines
Or stick the typedef in <
typedefs.h>, instead of trying to find (or create) some other common header.Probably better to just have a local
spapr_types.hinstead of polluting the global namespace.
I personally like this approach because it would allow to use the typedefs everywhere, for the sake of consistency.
Quoted 3 lines
Regards,
Daniel
Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/2] include/hw/ppc: Fix compilation with clang -std=gnu99
In reply to Paolo BonziniQuoted 5 lines · Paolo Bonzini
Quoted 4 lines · Daniel P. Berrangé
Quoted 1 line
so both files include each other, how nice ...
If the header files are mutually dependent it makes me wonder what the point of having them split up is ?
Quoted 7 lines
Quoted 2 lines
Feels like either they need to be merged, or they need to be split up and refactored even more to remove the mutual dependancy.
If they include each other only for the typedefs, then prehaps the solution is to change the coding style and allow using struct in function prototypes. I'm pretty sure there are several examples of this already.
I'm all in favor for this!
Thomas
Re: [Qemu-devel] [Qemu-ppc] [PATCH 1/2] include/hw/ppc: Fix compilation with clang -std=gnu99
In reply to Thomas HuthQuoted 106 lines · Thomas Huth
When compiling with Clang and -std=gnu99, I get the following errors:
CC
ppc64-softmmu/hw/intc/xics_spapr.o
In file included fromhw/intc/xics_spapr.c:34:include/hw/ppc/xics.h:46:25: error: redefinition of typedef 'ICSState' is a C11 feature
[-Werror,-Wtypedef-redefinition]typedef struct ICSState ICSState; ^ include/hw/ppc/spapr.h:18:25: note: previous definition is here typedef struct ICSState ICSState; ^ In file included from hw/intc/xics_spapr.c:34: include/hw/ppc/xics.h:203:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature [-Werror,-Wtypedef-redefinition] typedef struct sPAPRMachineState sPAPRMachineState; ^ include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here typedef struct sPAPRMachineState sPAPRMachineState; ^CC
ppc64-softmmu/hw/intc/spapr_xive.o
In file included fromhw/intc/spapr_xive.c:19:include/hw/ppc/spapr_xive.h:38:3: error: redefinition of typedef 'sPAPRXive' is a C11 feature
[-Werror,-Wtypedef-redefinition]
} sPAPRXive;
^include/hw/ppc/spapr.h:20:26: note: previous definition is heretypedef struct sPAPRXive sPAPRXive; ^ In file included from hw/intc/spapr_xive.c:19: include/hw/ppc/spapr_xive.h:45:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature [-Werror,-Wtypedef-redefinition] typedef struct sPAPRMachineState sPAPRMachineState; ^ include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here typedef struct sPAPRMachineState sPAPRMachineState; ^CC
ppc64-softmmu/hw/char/spapr_vty.o
In file included fromhw/char/spapr_vty.c:8:
In file included frominclude/hw/ppc/spapr.h:12:include/hw/ppc/spapr_xive.h:45:34: error: redefinition of typedef 'sPAPRMachineState' is a C11 feature
[-Werror,-Wtypedef-redefinition]typedef struct sPAPRMachineState sPAPRMachineState; ^ include/hw/ppc/spapr_irq.h:25:34: note: previous definition is here typedef struct sPAPRMachineState sPAPRMachineState; ^Since we're going to make -std=gnu99 mandatory, fix these issues by including the right header files indead of typedeffing stuff twice.
Signed-off-by Thomas Huth <[email protected]>--- include/hw/ppc/spapr.h | 4 ++-- include/hw/ppc/spapr_xive.h | 2 +- include/hw/ppc/xics.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-)include/hw/ppc/spapr.h +2
-2@@ -8,6 +8,8 @@#include "hw/mem/pc-dimm.h" #include "hw/ppc/spapr_ovec.h" #include "hw/ppc/spapr_irq.h" +#include "hw/ppc/xics.h" +#include "hw/ppc/spapr_xive.h" struct VIOsPAPRBus ;struct sPAPRPHBState ;@@ -15,8 +17,6 @@ struct sPAPRNVRAM;typedef struct sPAPREventLogEntry sPAPREventLogEntry ;typedef struct sPAPREventSource sPAPREventSource ;typedef struct sPAPRPendingHPT sPAPRPendingHPT ; -typedef struct ICSState ICSState ; -typedef struct sPAPRXive sPAPRXive ;#define HPTE64_V_HPTE_DIRTY 0x0000000000000040ULL#define SPAPR_ENTRY_POINT 0x100include/hw/ppc/spapr_xive.h +1
-1@@ -42,7 +42,7 @@ bool spapr_xive_irq_free(sPAPRXive *xive, uint32_t lisn);void spapr_xive_pic_print_info (sPAPRXive *xive,Monitor *mon);qemu_irq spapr_xive_qirq (sPAPRXive *xive,uint32_t lisn); -typedef struct sPAPRMachineState sPAPRMachineState ; +#include "hw/ppc/spapr.h" /* for sPAPRMachineState */ void spapr_xive_hcall_init (sPAPRMachineState *spapr); void spapr_dt_xive(sPAPRMachineState *spapr, uint32_t nr_servers, void *fdt,include/hw/ppc/xics.h +2
-0@@ -47,6 +47,8 @@ typedef struct ICSState ICSState;typedef struct ICSIRQState ICSIRQState ;typedef struct XICSFabric XICSFabric ; +#include "hw/ppc/spapr.h" +#define TYPE_ICP "icp"#define ICP (obj) OBJECT_CHECK(ICPState, (obj), TYPE_ICP)
include/hw/ppc/xics.h void ics_pic_print_info(ICSState *ics, Monitor *mon); · line 203
Quoted 2 lines
include/hw/ppc/xics.h +0
-0@@ -200,8 +202,6 @@ void ics_pic_print_info(ICSState *ics, Monitor *mon);void ics_resend (ICSState *ics);void icp_resend (ICPState *ss);
I think the definitions below belong to another header file, may be "xics_spapr.h". That would be cleaner.
Thanks,
C.
Quoted 6 lines
include/hw/ppc/xics.h +0
-2-typedef struct sPAPRMachineState sPAPRMachineState ; -void spapr_dt_xics (sPAPRMachineState *spapr,uint32_t nr_servers,void *fdt,uint32_t phandle);int xics_kvm_init (sPAPRMachineState *spapr,Error **errp);
PATCH v3 2/2 configure: Force the C standard to gnu99
In reply to Thomas HuthDifferent versions of GCC and Clang use different versions of the C standard. This repeatedly caused problems already, e.g. with duplicated typedefs:
https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg05829.html
or with for-loop variable initializers:
https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg00237.html
To avoid these problems, we should enforce the C language version to the same level for all compilers. Since our minimum compiler versions is GCC v4.8, our best option is "gnu99" for C code right now ("gnu17" is not available there yet, and "gnu11" is marked as "experimental"), and "gnu++98" for the few C++ code that we have in the repository.
---
v3: Compile C++ code with -std=gnu++98
configure | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
configure +4 -1
@@ -107,6 +107,9 @@ update_cxxflags() { -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\ -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls) ;; + -std=gnu99) + QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }"-std=gnu++98" + ;; *) QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg ;;
@@ -585,7 +588,7 @@ ARFLAGS="${ARFLAGS-rv}" # left shift of signed integers is well defined and has the expected # 2s-complement style results. (Both clang and gcc agree that it # provides these semantics.) -QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS" +QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv -std=gnu99 $QEMU_CFLAGS" QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
Signature · 1 line
1.8.3.1
Re: [Qemu-devel] [PATCH v3 2/2] configure: Force the C standard to gnu99
Quoted 9 lines · Thomas Huth
Different versions of GCC and Clang use different versions of the C standard. This repeatedly caused problems already, e.g. with duplicated typedefs:
https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg05829.html
or with for-loop variable initializers:
https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg00237.html
Quoted 7 lines
To avoid these problems, we should enforce the C language version to the same level for all compilers. Since our minimum compiler versions is GCC v4.8, our best option is "gnu99" for C code right now ("gnu17" is not available there yet, and "gnu11" is marked as "experimental"), and "gnu++98" for the few C++ code that we have in the repository.
Signed-off-by Thomas Huth <[email protected]>
Raising from a 30 years old stantard to a 20 years old one is a great improvement (I used to be a defender of the C89, but I evolved and now admit C99 has helpful features).
Using '-std=gnu++98' for g++ v4.8 looks like a good compromise to the issues Daniel mentioned (still 'experimental').
Quoted 30 lines
---
v3: Compile C++ code with -std=gnu++98configure | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)configure +4
-1@@ -107,6 +107,9 @@ update_cxxflags() { -Wstrict-prototypes|-Wmissing-prototypes|-Wnested-externs|\ -Wold-style-declaration|-Wold-style-definition|-Wredundant-decls) ;; + -std=gnu99) + QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }"-std=gnu++98" + ;; *) QEMU_CXXFLAGS=${QEMU_CXXFLAGS:+$QEMU_CXXFLAGS }$arg ;;@@ -585,7 +588,7 @@ ARFLAGS="${ARFLAGS-rv}" # left shift of signed integers is well defined and has the expected # 2s-complement style results. (Both clang and gcc agree that it # provides these semantics.) -QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS" +QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv -std=gnu99 $QEMU_CFLAGS" QEMU_CFLAGS="-Wall -Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS" QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS" QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
Re: [Qemu-devel] [PATCH v3 2/2] configure: Force the C standard to gnu99
Quoted 4 lines · Philippe Mathieu-Daudé
Using '-std=gnu++98' for g++ v4.8 looks like a good compromise to the issues Daniel mentioned (still 'experimental').
Reviewed-by Philippe Mathieu-Daudé <[email protected]>
C++11 has many new features that almost make it an entirely different language (the main being rvalue references, and type inference with auto and decltype). If it works for GCC 4.8, I would prefer using that instead of g++98.
Paolo
Re: [Qemu-devel] [PATCH v3 2/2] configure: Force the C standard to gnu99
Quoted 10 lines · Paolo Bonzini
Quoted 4 lines · Philippe Mathieu-Daudé
Using '-std=gnu++98' for g++ v4.8 looks like a good compromise to the issues Daniel mentioned (still 'experimental').
Reviewed-by Philippe Mathieu-Daudé <[email protected]>C++11 has many new features that almost make it an entirely different language (the main being rvalue references, and type inference with auto and decltype). If it works for GCC 4.8, I would prefer using that instead of g++98.
I think we can revisit that setting when we really want to introduce code that needs it. Currently it does not seem to be necessary, so that does not justify to use an "experimental" feature of GCC 4.8, I guess.
Thomas
Re: [Qemu-devel] [PATCH v3 2/2] configure: Force the C standard to gnu99
In reply to Thomas HuthQuoted 15 lines · Thomas Huth
Different versions of GCC and Clang use different versions of the C standard. This repeatedly caused problems already, e.g. with duplicated typedefs:
https://lists.gnu.org/archive/html/qemu-devel/2018-11/msg05829.html
or with for-loop variable initializers:
https://lists.gnu.org/archive/html/qemu-devel/2019-01/msg00237.html
To avoid these problems, we should enforce the C language version to the same level for all compilers. Since our minimum compiler versions is GCC v4.8, our best option is "gnu99" for C code right now ("gnu17" is not available there yet, and "gnu11" is marked as "experimental"), and "gnu++98" for the few C++ code that we have in the repository.
Quoted 3 lines
Signed-off-by Thomas Huth <[email protected]>---
v3: Compile C++ code with -std=gnu++98
r~