Skip to contentSkip to conversation

Can the empty struct rte_eth_txmode be enhanced?

DISCUSSION lxu 2 participants 2 messages Jun 12, 2013 1 message not in the archive

lore
Share & tools
lore

lxu

author
#0 lore raw

Hello all,I'm trying to write a C++ DPDK example. Everything is fine until I tried to enable RSS feature. It wasn't work.After hardy works, I found it's because empty structure rte_eth_txmode. In gcc the size of rte_eth_txmode is 0. But in g++ it's 1. I known the empty structure is a gcc extension. But it isn't be permitted by C99 (6.7.2.1/7 "Structure and union specifiers": "If the struct-declaration-list contains no named members, the behavior is undefined"). Can we change the struct rte_eth_txmode ? Such as : struct rte_eth_txmode { int reserve[]; }; /* sizeof(struct rte_eth_txmode) == 0 in gcc and g++ */

Acked-by
#2 lore raw
In reply to a message not in the archive

Hello,

Quoted 5 lines

Can we change the struct rte_eth_txmode ?

Such as :

struct rte_eth_txmode { int reserve[]; }; /* sizeof(struct rte_eth_txmode) == 0 in gcc and g++ */

I agree with your solution. Do you approve the following patch ?

From: lxu <[email protected]>
Date: Wed, 12 Jun 2013 09:32:30 +0200
Subject: [PATCH] ethdev: force the size of struct rte_eth_txmode to be 0

The size of an empty structure is 0 when compiling with gcc, and 1 when compiling with g++. Adding an empty table forces the size fo be 0, in C or C++.

---
 lib/librte_ether/rte_ethdev.h |    1 +
 1 file changed, 1 insertion(+)
lib/librte_ether/rte_ethdev.h +1 -0
index 5985496..e0a1ccf 100644
@@ -320,6 +320,7 @@ struct rte_eth_vmdq_dcb_conf {
  * For future extensions.
  */
 struct rte_eth_txmode {
+       int reserved[]; /* force the size of struct to be 0 */
 };
 
 /**
Signature · 1 line
1.7.10.4