On Fri, Jan 30, 2026 at 10:17:45PM +0100, Philippe Mathieu-Daudé wrote:
> 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.

What am I missing here - that text isn't talking about forward
declarations / typedefs ? It is just saying that the size of
an enum can vary betweeen compilers.


> 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;
>         |              ^
>   ...

Compliance with -Wpedantic is a non-goal for QEMU. We long ago
declared that our goal was only to support GCC/CLang, with the
GNU dialect of C, explicitly *NOT* strict compliance with ISO C.



> diff --git a/include/ui/kbd-state.h b/include/ui/kbd-state.h
> index 1f37b932eb6..3522ebe51b9 100644
> --- a/include/ui/kbd-state.h
> +++ b/include/ui/kbd-state.h
> @@ -9,9 +9,7 @@
>  
>  #include "qapi/qapi-types-ui.h"
>  
> -typedef enum QKbdModifier QKbdModifier;

Note this style...

> -
> -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;

...is a match for this style we use with structs, so this patch is forcing
divergence in styles.

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 :|


Reply via email to