* [PATCH] node: fix C++ compatibility errors (option 2)
@ 2025-06-30 10:50 Bruce Richardson
2025-07-01 13:04 ` Thomas Monjalon
2025-07-01 14:48 ` Nitin Saxena
0 siblings, 2 replies; 4+ messages in thread
From: Bruce Richardson @ 2025-06-30 10:50 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson
C++ does not allow zero-sized unions - they end up being of size 1-byte,
which leads to C/C++ compatibility issues, flagged by the compiler.
lib/node/rte_node_mbuf_dynfield.h:78:2: error: union has size 0 in C,
size 1 in C++ [-Werror,-Wextern-c-compat]
78 | union {
| ^
1 error generated.
Fix the error by omitting the persistent_data field when it is
zero-sized, since it's unusable. Any app using the field must already
specify a size for the persistent data.
Fixes: 746e8736da70 ("node: add global mbuf dynfield")
Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
lib/node/rte_node_mbuf_dynfield.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/node/rte_node_mbuf_dynfield.h b/lib/node/rte_node_mbuf_dynfield.h
index b77fdbb94f..09254c585a 100644
--- a/lib/node/rte_node_mbuf_dynfield.h
+++ b/lib/node/rte_node_mbuf_dynfield.h
@@ -69,6 +69,7 @@ typedef struct rte_node_mbuf_overload_fields {
* 2. Overloadable fields: Fields which can be repurposed by two adjacent nodes.
*/
typedef struct rte_node_mbuf_dynfield {
+#if RTE_NODE_MBUF_PERSISTENT_FIELDS_SIZE > 0
/**
* Persistent mbuf region across nodes in graph walk
*
@@ -78,6 +79,7 @@ typedef struct rte_node_mbuf_dynfield {
union {
uint8_t persistent_data[RTE_NODE_MBUF_PERSISTENT_FIELDS_SIZE];
};
+#endif
/**
* Overloadable mbuf fields across graph walk. Fields which can change.
*
--
2.48.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] node: fix C++ compatibility errors (option 2)
2025-06-30 10:50 [PATCH] node: fix C++ compatibility errors (option 2) Bruce Richardson
@ 2025-07-01 13:04 ` Thomas Monjalon
2025-07-01 14:48 ` Nitin Saxena
1 sibling, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2025-07-01 13:04 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev
30/06/2025 12:50, Bruce Richardson:
> C++ does not allow zero-sized unions - they end up being of size 1-byte,
> which leads to C/C++ compatibility issues, flagged by the compiler.
>
> lib/node/rte_node_mbuf_dynfield.h:78:2: error: union has size 0 in C,
> size 1 in C++ [-Werror,-Wextern-c-compat]
> 78 | union {
> | ^
> 1 error generated.
>
> Fix the error by omitting the persistent_data field when it is
> zero-sized, since it's unusable. Any app using the field must already
> specify a size for the persistent data.
[...]
> --- a/lib/node/rte_node_mbuf_dynfield.h
> +++ b/lib/node/rte_node_mbuf_dynfield.h
> @@ -69,6 +69,7 @@ typedef struct rte_node_mbuf_overload_fields {
> * 2. Overloadable fields: Fields which can be repurposed by two adjacent nodes.
> */
> typedef struct rte_node_mbuf_dynfield {
> +#if RTE_NODE_MBUF_PERSISTENT_FIELDS_SIZE > 0
> /**
> * Persistent mbuf region across nodes in graph walk
> *
> @@ -78,6 +79,7 @@ typedef struct rte_node_mbuf_dynfield {
> union {
> uint8_t persistent_data[RTE_NODE_MBUF_PERSISTENT_FIELDS_SIZE];
> };
> +#endif
I didn't do a deep analysis but I think I would prefer this option 2.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] node: fix C++ compatibility errors (option 2)
2025-06-30 10:50 [PATCH] node: fix C++ compatibility errors (option 2) Bruce Richardson
2025-07-01 13:04 ` Thomas Monjalon
@ 2025-07-01 14:48 ` Nitin Saxena
2025-07-02 10:00 ` Thomas Monjalon
1 sibling, 1 reply; 4+ messages in thread
From: Nitin Saxena @ 2025-07-01 14:48 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev
On Mon, Jun 30, 2025 at 4:27 PM Bruce Richardson
<bruce.richardson@intel.com> wrote:
>
> C++ does not allow zero-sized unions - they end up being of size 1-byte,
> which leads to C/C++ compatibility issues, flagged by the compiler.
>
> lib/node/rte_node_mbuf_dynfield.h:78:2: error: union has size 0 in C,
> size 1 in C++ [-Werror,-Wextern-c-compat]
> 78 | union {
> | ^
> 1 error generated.
>
> Fix the error by omitting the persistent_data field when it is
> zero-sized, since it's unusable. Any app using the field must already
> specify a size for the persistent data.
>
> Fixes: 746e8736da70 ("node: add global mbuf dynfield")
>
> Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
> ---
> lib/node/rte_node_mbuf_dynfield.h | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/lib/node/rte_node_mbuf_dynfield.h b/lib/node/rte_node_mbuf_dynfield.h
> index b77fdbb94f..09254c585a 100644
> --- a/lib/node/rte_node_mbuf_dynfield.h
> +++ b/lib/node/rte_node_mbuf_dynfield.h
> @@ -69,6 +69,7 @@ typedef struct rte_node_mbuf_overload_fields {
> * 2. Overloadable fields: Fields which can be repurposed by two adjacent nodes.
> */
> typedef struct rte_node_mbuf_dynfield {
> +#if RTE_NODE_MBUF_PERSISTENT_FIELDS_SIZE > 0
> /**
> * Persistent mbuf region across nodes in graph walk
> *
> @@ -78,6 +79,7 @@ typedef struct rte_node_mbuf_dynfield {
> union {
> uint8_t persistent_data[RTE_NODE_MBUF_PERSISTENT_FIELDS_SIZE];
> };
> +#endif
> /**
> * Overloadable mbuf fields across graph walk. Fields which can change.
> *
> --
> 2.48.1
>
Acked-by: Nitin Saxena <nsaxena@marvell.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] node: fix C++ compatibility errors (option 2)
2025-07-01 14:48 ` Nitin Saxena
@ 2025-07-02 10:00 ` Thomas Monjalon
0 siblings, 0 replies; 4+ messages in thread
From: Thomas Monjalon @ 2025-07-02 10:00 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev, Nitin Saxena
01/07/2025 16:48, Nitin Saxena:
> On Mon, Jun 30, 2025 at 4:27 PM Bruce Richardson
> <bruce.richardson@intel.com> wrote:
> >
> > C++ does not allow zero-sized unions - they end up being of size 1-byte,
> > which leads to C/C++ compatibility issues, flagged by the compiler.
> >
> > lib/node/rte_node_mbuf_dynfield.h:78:2: error: union has size 0 in C,
> > size 1 in C++ [-Werror,-Wextern-c-compat]
> > 78 | union {
> > | ^
> > 1 error generated.
> >
> > Fix the error by omitting the persistent_data field when it is
> > zero-sized, since it's unusable. Any app using the field must already
> > specify a size for the persistent data.
> >
> > Fixes: 746e8736da70 ("node: add global mbuf dynfield")
> >
> > Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
>
> Acked-by: Nitin Saxena <nsaxena@marvell.com>
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-07-02 10:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-06-30 10:50 [PATCH] node: fix C++ compatibility errors (option 2) Bruce Richardson
2025-07-01 13:04 ` Thomas Monjalon
2025-07-01 14:48 ` Nitin Saxena
2025-07-02 10:00 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).