bulk: Stop forward-declaring enum typedefs
cover bulk: Stop forward-declaring enum typedefs
The C99 standard chapter §6.7.2.2 point 4 mentions:
Each enumerated type shall be compatible with char, a signed integer type, or an unsigned integer type. The choice of type is implementation-defined, but shall be capable of representing the values of all the members of the enumeration.
Align with that recommendation by defining the typedef along with the enum.
Philippe Mathieu-Daudé (2):
bulk: Stop forward-declaring enum typedefs
docs/devel: Mention enum typedefs forward-declaration is not allowed
docs/devel/style.rst | 11 +++++++++++ hw/riscv/riscv-iommu-bits.h | 4 ++-- hw/riscv/riscv-iommu.h | 2 -- include/hw/misc/auxbus.h | 11 ++++------- include/hw/pci/pci_device.h | 5 ++--- include/hw/ssi/ssi.h | 6 ++---- include/hw/xen/interface/io/xenbus.h | 5 ++--- include/io/channel.h | 11 ++++------- include/system/replay.h | 10 ++++------ include/ui/clipboard.h | 15 ++++++--------- include/ui/kbd-state.h | 6 ++---- pc-bios/s390-ccw/virtio.h | 5 ++--- tests/qtest/libqos/qgraph_internal.h | 10 ++++------ hw/core/loader.c | 5 ++--- hw/display/xlnx_dp.c | 11 ++++------- hw/dma/xlnx_dpdma.c | 10 ++++------ qapi/opts-visitor.c | 7 ++----- qapi/string-output-visitor.c | 6 ++---- tests/unit/check-qom-proplist.c | 6 ++---- 19 files changed, 61 insertions(+), 85 deletions(-)
Signature · 1 line
2.52.0
PATCH 1/2 bulk: Stop forward-declaring enum typedefs
The C99 standard chapter §6.7.2.2 point 4 mentions:
Each enumerated type shall be compatible with char, a signed integer type, or an unsigned integer type. The choice of type is implementation-defined, but shall be capable of representing the values of all the members of the enumeration.
Align with that recommendation by defining the typedef along with the enum.
For information, building with -Werror=pedantic was reporting:
In file included from ../../ui/kbd-state.c:10:
include/ui/kbd-state.h:12:14: error: ISO C forbids forward references to 'enum' types [-Werror,-Wpedantic]
12 | typedef enum QKbdModifier QKbdModifier;
| ^...
--- hw/riscv/riscv-iommu-bits.h | 4 ++-- hw/riscv/riscv-iommu.h | 2 -- include/hw/misc/auxbus.h | 11 ++++------- include/hw/pci/pci_device.h | 5 ++--- include/hw/ssi/ssi.h | 6 ++---- include/hw/xen/interface/io/xenbus.h | 5 ++--- include/io/channel.h | 11 ++++------- include/system/replay.h | 10 ++++------ include/ui/clipboard.h | 15 ++++++--------- include/ui/kbd-state.h | 6 ++---- pc-bios/s390-ccw/virtio.h | 5 ++--- tests/qtest/libqos/qgraph_internal.h | 10 ++++------ hw/core/loader.c | 5 ++--- hw/display/xlnx_dp.c | 11 ++++------- hw/dma/xlnx_dpdma.c | 10 ++++------ qapi/opts-visitor.c | 7 ++----- qapi/string-output-visitor.c | 6 ++---- tests/unit/check-qom-proplist.c | 6 ++---- 18 files changed, 50 insertions(+), 85 deletions(-)
hw/riscv/riscv-iommu-bits.h +2 -2
@@ -96,11 +96,11 @@ struct riscv_iommu_pq_record {#define RISCV_IOMMU_CAP_PD17 BIT_ULL(39)#define RISCV_IOMMU_CAP_PD20 BIT_ULL(40) -enum riscv_iommu_igs_modes { +typedef enum riscv_iommu_igs_modes {RISCV_IOMMU_CAP_IGS_MSI =0 ,RISCV_IOMMU_CAP_IGS_WSI ,RISCV_IOMMU_CAP_IGS_BOTH -}; +}riscv_iommu_igs_mode ;/* 5.4 Features control register (32bits) */ #define RISCV_IOMMU_REG_FCTL 0x0008
hw/riscv/riscv-iommu.h +0 -2
@@ -25,8 +25,6 @@#include "hw/riscv/iommu.h" #include "hw/riscv/riscv-iommu-bits.h" -typedef enum riscv_iommu_igs_modes riscv_iommu_igs_mode ; -struct RISCVIOMMUState {/*< private >*/ DeviceState parent_obj;
include/hw/misc/auxbus.h +4 -7
@@ -29,16 +29,13 @@#include "hw/core/qdev.h" #include "qom/object.h" -typedef enum AUXCommand AUXCommand ; -typedef enum AUXReply AUXReply ; -#define TYPE_AUXTOI2C "aux-to-i2c-bridge" OBJECT_DECLARE_SIMPLE_TYPE(AUXTOI2CState, AUXTOI2C)#define TYPE_AUX_SLAVE "aux-slave" OBJECT_DECLARE_SIMPLE_TYPE(AUXSlave, AUX_SLAVE) -enum AUXCommand { +typedef enum AUXCommand { WRITE_I2C = 0, READ_I2C = 1, WRITE_I2C_STATUS = 2,
@@ -46,15 +43,15 @@ enum AUXCommand {READ_I2C_MOT =5 ,WRITE_AUX =8 , READ_AUX = 9 -}; +} AUXCommand; -enum AUXReply { +typedef enum AUXReply {AUX_I2C_ACK =0 ,AUX_NACK =1 ,AUX_DEFER =2 ,AUX_I2C_NACK =4 ,AUX_I2C_DEFER =8 -}; +}AUXReply ;#define TYPE_AUX_BUS "aux-bus"OBJECT_DECLARE_SIMPLE_TYPE (AUXBus,AUX_BUS )
include/hw/pci/pci_device.h +2 -3
@@ -43,13 +43,12 @@ struct PCIDeviceClass {bool sriov_vf_user_creatable; }; -enum PCIReqIDType { +typedef enum PCIReqIDType {PCI_REQ_ID_INVALID =0 ,PCI_REQ_ID_BDF ,PCI_REQ_ID_SECONDARY_BUS ,PCI_REQ_ID_MAX , -}; -typedef enum PCIReqIDType PCIReqIDType ; +}PCIReqIDType ;struct PCIReqIDCache {PCIDevice *dev;
include/hw/ssi/ssi.h +2 -4
@@ -16,19 +16,17 @@#include "hw/core/qdev.h" #include "qom/object.h" -typedef enum SSICSMode SSICSMode ; -#define TYPE_SSI_PERIPHERAL "ssi-peripheral"OBJECT_DECLARE_TYPE (SSIPeripheral, SSIPeripheralClass, SSI_PERIPHERAL)#define SSI_GPIO_CS "ssi-gpio-cs" -enum SSICSMode { +typedef enum SSICSMode {SSI_CS_NONE =0 ,SSI_CS_LOW ,SSI_CS_HIGH , -}; +}SSICSMode ;/* Peripherals. */ struct SSIPeripheralClass {
include/hw/xen/interface/io/xenbus.h +2 -3
@@ -16,7 +16,7 @@* the state of the connection between the driver and the kernel's device * layers. */ -enum xenbus_state { +typedef enum xenbus_state { XenbusStateUnknown = 0, XenbusStateInitialising = 1,
@@ -47,8 +47,7 @@ enum xenbus_state { XenbusStateReconfiguring =7 , XenbusStateReconfigured =8 -}; -typedef enum xenbus_state XenbusState ; +} XenbusState;#endif /* _XEN_PUBLIC_IO_XENBUS_H */
include/io/channel.h +4 -7
@@ -38,9 +38,8 @@ OBJECT_DECLARE_TYPE(QIOChannel, QIOChannelClass,#define QIO_CHANNEL_READ_FLAG_RELAXED_EOF 0x2#define QIO_CHANNEL_READ_FLAG_FD_PRESERVE_BLOCKING 0x4 -typedef enum QIOChannelFeature QIOChannelFeature ; -enum QIOChannelFeature { +typedef enum QIOChannelFeature { QIO_CHANNEL_FEATURE_FD_PASS, QIO_CHANNEL_FEATURE_SHUTDOWN, QIO_CHANNEL_FEATURE_LISTEN,
@@ -48,16 +47,14 @@ enum QIOChannelFeature {QIO_CHANNEL_FEATURE_READ_MSG_PEEK ,QIO_CHANNEL_FEATURE_SEEKABLE ,QIO_CHANNEL_FEATURE_CONCURRENT_IO , -}; +} QIOChannelFeature; -typedef enum QIOChannelShutdown QIOChannelShutdown ; - -enum QIOChannelShutdown { +typedef enum QIOChannelShutdown {QIO_CHANNEL_SHUTDOWN_READ =1 ,QIO_CHANNEL_SHUTDOWN_WRITE =2 ,QIO_CHANNEL_SHUTDOWN_BOTH =3 , -}; +}QIOChannelShutdown ; typedef gboolean (*QIOChannelFunc)(QIOChannel *ioc, GIOCondition condition,
include/system/replay.h +4 -6
@@ -19,17 +19,16 @@#include "qemu/audio.h" /* replay clock kinds */ -enum ReplayClockKind { +typedef enum ReplayClockKind {/* host_clock */ REPLAY_CLOCK_HOST ,/* virtual_rt_clock */ REPLAY_CLOCK_VIRTUAL_RT ,REPLAY_CLOCK_COUNT -}; -typedef enum ReplayClockKind ReplayClockKind ; +}ReplayClockKind ;/* IDs of the checkpoints */ -enum ReplayCheckpoint { +typedef enum ReplayCheckpoint { CHECKPOINT_CLOCK_WARP_START, CHECKPOINT_CLOCK_WARP_ACCOUNT, CHECKPOINT_RESET_REQUESTED,
@@ -40,8 +39,7 @@ enum ReplayCheckpoint {CHECKPOINT_INIT ,CHECKPOINT_RESET , CHECKPOINT_COUNT -}; -typedef enum ReplayCheckpoint ReplayCheckpoint ; +} ReplayCheckpoint;typedef struct ReplayNetState ReplayNetState ;
include/ui/clipboard.h +6 -9
@@ -20,9 +20,6 @@* is supported for now. */ -typedef enum QemuClipboardType QemuClipboardType ; -typedef enum QemuClipboardNotifyType QemuClipboardNotifyType ; -typedef enum QemuClipboardSelection QemuClipboardSelection ;typedef struct QemuClipboardPeer QemuClipboardPeer ;typedef struct QemuClipboardNotify QemuClipboardNotify ;typedef struct QemuClipboardInfo QemuClipboardInfo ;
@@ -36,10 +33,10 @@ extern const VMStateDescription vmstate_cbinfo;* @QEMU_CLIPBOARD_TYPE_TEXT: text/plain; charset=utf-8 * @QEMU_CLIPBOARD_TYPE__COUNT: type count. */ -enum QemuClipboardType { +typedef enum QemuClipboardType {QEMU_CLIPBOARD_TYPE_TEXT ,QEMU_CLIPBOARD_TYPE__COUNT , -}; +}QemuClipboardType ;/* same as VD_AGENT_CLIPBOARD_SELECTION_* */ /**
@@ -50,12 +47,12 @@ enum QemuClipboardType {* @QEMU_CLIPBOARD_SELECTION_SECONDARY: secondary selection (dunno). * @QEMU_CLIPBOARD_SELECTION__COUNT: selection count. */ -enum QemuClipboardSelection { +typedef enum QemuClipboardSelection {QEMU_CLIPBOARD_SELECTION_CLIPBOARD ,QEMU_CLIPBOARD_SELECTION_PRIMARY ,QEMU_CLIPBOARD_SELECTION_SECONDARY ,QEMU_CLIPBOARD_SELECTION__COUNT , -}; +}QemuClipboardSelection ;/** * struct QemuClipboardPeer
@@ -81,10 +78,10 @@ struct QemuClipboardPeer {* * Clipboard notify type. */ -enum QemuClipboardNotifyType { +typedef enum QemuClipboardNotifyType {QEMU_CLIPBOARD_UPDATE_INFO ,QEMU_CLIPBOARD_RESET_SERIAL , -}; +}QemuClipboardSelection ;/** * struct QemuClipboardNotify
include/ui/kbd-state.h +2 -4
@@ -9,9 +9,7 @@#include "qapi/qapi-types-ui.h" -typedef enum QKbdModifier QKbdModifier ; - -enum QKbdModifier { +typedef enum QKbdModifier { QKBD_MOD_NONE = 0, QKBD_MOD_SHIFT,
@@ -23,7 +21,7 @@ enum QKbdModifier {QKBD_MOD_CAPSLOCK , QKBD_MOD__MAX -}; +} QKbdModifier;typedef struct QKbdState QKbdState ;
pc-bios/s390-ccw/virtio.h +2 -3
@@ -173,13 +173,12 @@ struct VirtioBlkConfig { } __attribute__((packed));typedef struct VirtioBlkConfig VirtioBlkConfig ; -enum guessed_disk_nature_type { +typedef enum guessed_disk_nature_type {VIRTIO_GDN_NONE =0 ,VIRTIO_GDN_DASD =1 ,VIRTIO_GDN_CDROM =2 ,VIRTIO_GDN_SCSI =3 , -}; -typedef enum guessed_disk_nature_type VirtioGDN ; +}VirtioGDN ;VirtioGDN virtio_guessed_disk_nature (void );void virtio_assume_eckd (void );
tests/qtest/libqos/qgraph_internal.h +4 -6
@@ -27,8 +27,6 @@#include "qgraph.h" typedef struct QOSGraphMachine QOSGraphMachine ; -typedef enum QOSEdgeType QOSEdgeType ; -typedef enum QOSNodeType QOSNodeType ;/* callback called when the walk path algorithm found a * valid path
@@ -36,19 +34,19 @@ typedef enum QOSNodeType QOSNodeType;typedef void (*QOSTestCallback ) (QOSGraphNode *path,int len);/* edge types*/ -enum QOSEdgeType { +typedef enum QOSEdgeType {QEDGE_CONTAINS ,QEDGE_PRODUCES ,QEDGE_CONSUMED_BY -}; +}QOSEdgeType ;/* node types*/ -enum QOSNodeType { +typedef enum QOSNodeType {QNODE_MACHINE ,QNODE_DRIVER ,QNODE_INTERFACE ,QNODE_TEST -}; +}QOSNodeType ;/* Graph Node */ struct QOSGraphNode {
hw/core/loader.c +2 -3
@@ -1688,15 +1688,14 @@ HumanReadableText *qmp_x_query_roms(Error **errp)return human_readable_text_from_str (buf); } -typedef enum HexRecord HexRecord ; -enum HexRecord { +typedef enum HexRecord {DATA_RECORD =0 ,EOF_RECORD ,EXT_SEG_ADDR_RECORD ,START_SEG_ADDR_RECORD ,EXT_LINEAR_ADDR_RECORD ,START_LINEAR_ADDR_RECORD , -}; +}HexRecord ;/* Each record contains a 16-bit address which is combined with the upper 16 * bits of the implicit "next address" to form a 32-bit address.
hw/display/xlnx_dp.c +4 -7
@@ -212,7 +212,7 @@#define DP_GRAPHIC_DMA_CHANNEL (3)#define DP_VIDEO_DMA_CHANNEL (0) -enum DPGraphicFmt { +typedef enum DPGraphicFmt { DP_GRAPHIC_RGBA8888 = 0 << 8, DP_GRAPHIC_ABGR8888 = 1 << 8, DP_GRAPHIC_RGB888 = 2 << 8,
@@ -225,9 +225,9 @@ enum DPGraphicFmt {DP_GRAPHIC_2BPP =9 <<8 ,DP_GRAPHIC_1BPP =10 <<8 , DP_GRAPHIC_MASK = 0xF << 8 -}; +} DPGraphicFmt; -enum DPVideoFmt { +typedef enum DPVideoFmt { DP_NL_VID_CB_Y0_CR_Y1 = 0, DP_NL_VID_CR_Y0_CB_Y1 = 1, DP_NL_VID_Y0_CR_Y1_CB = 2,
@@ -254,10 +254,7 @@ enum DPVideoFmt {DP_NL_VID_YV16CL_420_10BPC =23 ,DP_NL_VID_YV16CL2_420_10BPC =24 , DP_NL_VID_FMT_MASK = 0x1F -}; - -typedef enum DPGraphicFmt DPGraphicFmt ; -typedef enum DPVideoFmt DPVideoFmt ; +} DPVideoFmt;static const VMStateDescription vmstate_dp = { .name =TYPE_XLNX_DP ,
hw/dma/xlnx_dpdma.c +4 -6
@@ -122,15 +122,15 @@#define DPDMA_FRAG_MAX_SZ (4096) -enum DPDMABurstType { +typedef enum DPDMABurstType {DPDMA_INCR =0 ,DPDMA_FIXED =1 -}; +}DPDMABurstType ; -enum DPDMAMode { +typedef enum DPDMAMode {DPDMA_CONTIGOUS =0 ,DPDMA_FRAGMENTED =1 -}; +}DPDMAMode ;struct DPDMADescriptor {uint32_t control;
@@ -153,8 +153,6 @@ struct DPDMADescriptor {uint32_t crc; }; -typedef enum DPDMABurstType DPDMABurstType ; -typedef enum DPDMAMode DPDMAMode ;typedef struct DPDMADescriptor DPDMADescriptor ;static bool xlnx_dpdma_desc_is_last (DPDMADescriptor *desc)
qapi/opts-visitor.c +2 -5
@@ -20,8 +20,7 @@#include "qapi/visitor-impl.h" -enum ListMode -{ +typedef enum ListMode { LM_NONE, /* not traversing a list of repeated options */ LM_IN_PROGRESS, /*
@@ -58,9 +57,7 @@ enum ListMode* No more QemuOpt instance in the list. * The traversal has been completed. */ -}; - -typedef enum ListMode ListMode ; +} ListMode;struct OptsVisitor {
qapi/string-output-visitor.c +2 -4
@@ -17,7 +17,7 @@#include <math.h> #include "qemu/range.h" -enum ListMode { +typedef enum ListMode { LM_NONE, /* not traversing a list of repeated options */ LM_STARTED, /* next_list() ready to be called */
@@ -48,9 +48,7 @@ enum ListMode {LM_UNSIGNED_INTERVAL ,/* Same as above, only for an unsigned interval. */ LM_END ,/* next_list() called, about to see last element. */ -}; - -typedef enum ListMode ListMode ; +} ListMode;struct StringOutputVisitor {
tests/unit/check-qom-proplist.c +2 -4
@@ -40,15 +40,13 @@ typedef struct DummyObjectClass DummyObjectClass;DECLARE_INSTANCE_CHECKER (DummyObject,DUMMY_OBJECT , TYPE_DUMMY) -typedef enum DummyAnimal DummyAnimal ; - -enum DummyAnimal { +typedef enum DummyAnimal {DUMMY_FROG ,DUMMY_ALLIGATOR ,DUMMY_PLATYPUS ,DUMMY_LAST , -}; +}DummyAnimal ;const QEnumLookup dummy_animal_map = { .array = (const char *const []) {
Signature · 1 line
2.52.0
Quoted 32 lines · Philippe Mathieu-Daudé
The C99 standard chapter §6.7.2.2 point 4 mentions:
Each enumerated type shall be compatible with char, a signed integer type, or an unsigned integer type. The choice of type is implementation-defined, but shall be capable of representing the values of all the members of the enumeration.
Align with that recommendation by defining the typedef along with the enum.
For information, building with -Werror=pedantic was reporting:
In file included from ../../ui/kbd-state.c:10: include/ui/kbd-state.h:12:14: error: ISO C forbids forward references to 'enum' types [-Werror,-Wpedantic] 12 | typedef enum QKbdModifier QKbdModifier; | ^ ...Reported-by Roman Kiryanov <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/riscv/riscv-iommu-bits.h | 4 ++-- hw/riscv/riscv-iommu.h | 2 -- include/hw/misc/auxbus.h | 11 ++++------- include/hw/pci/pci_device.h | 5 ++--- include/hw/ssi/ssi.h | 6 ++---- include/hw/xen/interface/io/xenbus.h | 5 ++--- include/io/channel.h | 11 ++++------- include/system/replay.h | 10 ++++------ include/ui/clipboard.h | 15 ++++++--------- include/ui/kbd-state.h | 6 ++---- pc-bios/s390-ccw/virtio.h | 5 ++---
Quoted 9 lines
tests/qtest/libqos/qgraph_internal.h | 10 ++++------ hw/core/loader.c | 5 ++--- hw/display/xlnx_dp.c | 11 ++++------- hw/dma/xlnx_dpdma.c | 10 ++++------ qapi/opts-visitor.c | 7 ++----- qapi/string-output-visitor.c | 6 ++---- tests/unit/check-qom-proplist.c | 6 ++---- 18 files changed, 50 insertions(+), 85 deletions(-)
This looks good!
Quoted 85 lines · Philippe Mathieu-Daudé
The C99 standard chapter §6.7.2.2 point 4 mentions:
Each enumerated type shall be compatible with char, a signed integer type, or an unsigned integer type. The choice of type is implementation-defined, but shall be capable of representing the values of all the members of the enumeration.
Align with that recommendation by defining the typedef along with the enum.
For information, building with -Werror=pedantic was reporting:
In file included from ../../ui/kbd-state.c:10: include/ui/kbd-state.h:12:14: error: ISO C forbids forward references to 'enum' types [-Werror,-Wpedantic] 12 | typedef enum QKbdModifier QKbdModifier; | ^ ...Reported-by Roman Kiryanov <[email protected]>Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/riscv/riscv-iommu-bits.h | 4 ++-- hw/riscv/riscv-iommu.h | 2 -- include/hw/misc/auxbus.h | 11 ++++------- include/hw/pci/pci_device.h | 5 ++--- include/hw/ssi/ssi.h | 6 ++---- include/hw/xen/interface/io/xenbus.h | 5 ++--- include/io/channel.h | 11 ++++------- include/system/replay.h | 10 ++++------ include/ui/clipboard.h | 15 ++++++--------- include/ui/kbd-state.h | 6 ++---- pc-bios/s390-ccw/virtio.h | 5 ++--- tests/qtest/libqos/qgraph_internal.h | 10 ++++------ hw/core/loader.c | 5 ++--- hw/display/xlnx_dp.c | 11 ++++------- hw/dma/xlnx_dpdma.c | 10 ++++------ qapi/opts-visitor.c | 7 ++----- qapi/string-output-visitor.c | 6 ++---- tests/unit/check-qom-proplist.c | 6 ++---- 18 files changed, 50 insertions(+), 85 deletions(-)include/ui/clipboard.h +4
-7@@ -20,9 +20,6 @@* is supported for now. */ -typedef enum QemuClipboardType QemuClipboardType ; -typedef enum QemuClipboardNotifyType QemuClipboardNotifyType ; -typedef enum QemuClipboardSelection QemuClipboardSelection ;typedef struct QemuClipboardPeer QemuClipboardPeer ;typedef struct QemuClipboardNotify QemuClipboardNotify ;typedef struct QemuClipboardInfo QemuClipboardInfo ;@@ -36,10 +33,10 @@ extern const VMStateDescription vmstate_cbinfo;* @QEMU_CLIPBOARD_TYPE_TEXT: text/plain; charset=utf-8 * @QEMU_CLIPBOARD_TYPE__COUNT: type count. */ -enum QemuClipboardType { +typedef enum QemuClipboardType {QEMU_CLIPBOARD_TYPE_TEXT ,QEMU_CLIPBOARD_TYPE__COUNT , -}; +}QemuClipboardType ;/* same as VD_AGENT_CLIPBOARD_SELECTION_* */ /** @@ -50,12 +47,12 @@ enum QemuClipboardType {* @QEMU_CLIPBOARD_SELECTION_SECONDARY: secondary selection (dunno). * @QEMU_CLIPBOARD_SELECTION__COUNT: selection count. */ -enum QemuClipboardSelection { +typedef enum QemuClipboardSelection {QEMU_CLIPBOARD_SELECTION_CLIPBOARD ,QEMU_CLIPBOARD_SELECTION_PRIMARY ,QEMU_CLIPBOARD_SELECTION_SECONDARY ,QEMU_CLIPBOARD_SELECTION__COUNT , -}; +}QemuClipboardSelection ;/** * struct QemuClipboardPeer
include/ui/clipboard.h struct QemuClipboardPeer { · line 84
Quoted 9 lines
include/ui/clipboard.h +2
-2@@ -81,10 +78,10 @@ struct QemuClipboardPeer {* * Clipboard notify type. */ -enum QemuClipboardNotifyType { +typedef enum QemuClipboardNotifyType {QEMU_CLIPBOARD_UPDATE_INFO ,QEMU_CLIPBOARD_RESET_SERIAL , -}; +}QemuClipboardSelection ;
Oops, squashing this:
-- >8 --
include/ui/clipboard.h +1 -1
@@ -81,7 +81,7 @@ struct QemuClipboardPeer {typedef enum QemuClipboardNotifyType {QEMU_CLIPBOARD_UPDATE_INFO ,QEMU_CLIPBOARD_RESET_SERIAL , -}QemuClipboardSelection ; +}QemuClipboardNotifyType ;/** * struct QemuClipboardNotify
---
PATCH 2/2 docs/devel: Mention enum typedefs forward-declaration is not allowed
In reply to Philippe Mathieu-DaudéDo not allow enum typedef forward-declaration to comply with C99 standard chapter §6.7.2.2 point 4:
Each enumerated type shall be compatible with char, a signed integer type, or an unsigned integer type. The choice of type is implementation-defined, but shall be capable of representing the values of all the members of the enumeration.
--- docs/devel/style.rst | 11 +++++++++++ 1 file changed, 11 insertions(+)
docs/devel/style.rst +11 -0
@@ -416,6 +416,17 @@ definitions instead of typedefs in headers and function prototypes; this avoids problems with duplicated typedefs and reduces the need to include headers from other headers. +Enumeration (enum) type can not be forward declared as typedef, because +C compilers should be able to know the size of enums before hand. Simply +define the typedef along with the enum: + +.. code-block:: c + + typedef enum MyEnum { + FOO, + BAR, + } MyEnum; + Bitfields ---------
Signature · 1 line
2.52.0
Re: [PATCH 2/2] docs/devel: Mention enum typedefs forward-declaration is not allowed
Quoted 8 lines · Philippe Mathieu-Daudé
Do not allow enum typedef forward-declaration to comply with C99 standard chapter §6.7.2.2 point 4:
Each enumerated type shall be compatible with char, a signed integer type, or an unsigned integer type. The choice of type is implementation-defined, but shall be capable of representing the values of all the members of the enumeration.
Quoted 5 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- docs/devel/style.rst | 11 +++++++++++ 1 file changed, 11 insertions(+)
Shall we modify checkpatch as well, to make sure it doesn't come back? It's easy to detect with a single line regexp.