gen: don't create typedefs for enums
If a enum typedef is backported to an old release, the public header
file definition will clash with our typedef, because the compiler
will not consider an "int" to be equivalent to an "enum".
This is seen currently with CentOS Stream 9:
In file included from ./libvirt_generated.h:41,
from ./libvirt_admin_generated.h:39,
from ./admin_helper.h:29,
from ./admin.go:36:
./libvirt_generated_typedefs.h:280:13: error: conflicting types for 'virConnectGetDomainCapabilitiesFlags'; have 'int'
280 | typedef int virConnectGetDomainCapabilitiesFlags;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/libvirt/libvirt.h:36,
from /usr/include/libvirt/virterror.h:27,
from ./libvirt_admin_generated.h:36,
from ./admin_helper.h:29,
from ./admin.go:36:
/usr/include/libvirt/libvirt-domain.h:1504:3: note: previous declaration of 'virConnectGetDomainCapabilitiesFlags' with type 'virConnectGetDomainCapabilitiesFlags'
1504 | } virConnectGetDomainCapabilitiesFlags;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Since the Go bindings don't require the enum typedef, only the
constants, simplest solution is to simply not generate the
typedefs.
The only exception is the 'virErrorLevel' enum which was mistakenly
included in the public declaration of the 'virError' struct.
Signed-off-by:
Daniel P. Berrangé <berrange@redhat.com>
Loading
Please register or sign in to comment