[libvirt] RFC: fixing struct name in public header

Michal Privoznik mprivozn at redhat.com
Wed Apr 12 13:01:35 UTC 2017


On 04/12/2017 01:31 PM, Daniel P. Berrange wrote:
> Take a look at this def from libvirt-domain.h:
>
> typedef struct _virDomainInterfaceIPAddress virDomainIPAddress;
> typedef virDomainIPAddress *virDomainIPAddressPtr;
> struct _virDomainInterfaceIPAddress {
>     int type;                /* virIPAddrType */
>     char *addr;              /* IP address */
>     unsigned int prefix;     /* IP address prefix */
> };
>
>
> Notice the struct name is different from the typedef names.
>
> Technically renaming the struct to remove the 'Interface' word
> would be an API break.
>
> On the flip side though we don't expect any apps to use the struct
> name, but rather use the typedefs, hence use of '_' in the name.
>
> We could do what we did with the typed parameter stuff and rename
> the struct, but add a
>
>   #define _virDomainInterfaceIPAddress _virDomainIPAddress
>
> Any thoughts ?

I'd rename it even without the additional #define. APPs should favour 
the type instead of using struct _virBlah. We have it there because 
there's no other way to expose the struct members to callers in C.

Michal




More information about the libvir-list mailing list