Anonymous structs in DPDK

Ferruh Yigit ferruh.yigit at amd.com
Tue Dec 13 14:55:10 CET 2022


On 12/13/2022 12:51 PM, Antonio Di Bacco wrote:
> I noticed that DPDK include files have a number of anonymous/unnamed struct:
> 
> For example:
> 
> /**
>  * The rte_spinlock_t type.
>  */
> typedef struct {
>         volatile int locked; /**< lock status 0 = unlocked, 1 = locked */
> } rte_spinlock_t;
> 
> This choice doesn't allow to use forward declaration. I need forward
> declaration because I'm using a rte_spinlock_t pointer in a C++ class
> and I don't want to include rte_spinlock.h to prevent my application
> to include it as well.
> 
> Is there any reason to use unnamed structures?
> 

Hi Antonio Di,

I don't think there is a specific reason to not use named struct, I
assume that is only because there was no need to have it.

So if you need, you can send a simple patch to convert anonymous struct
to named struct, although I am not clear why you can't include
'rte_spinlock.h' in the file you declare your class.

Cheers,
ferruh


More information about the users mailing list