DPDK patches and discussions
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: dev@dpdk.org
Cc: Bruce Richardson <bruce.richardson@intel.com>
Subject: [PATCH] node: fix C++ compatibility errors (option 1)
Date: Mon, 30 Jun 2025 11:49:40 +0100	[thread overview]
Message-ID: <20250630104939.2265866-2-bruce.richardson@intel.com> (raw)

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 defaulting to a having a 1-byte sized union rather than
zero-sized.

Fixes: 746e8736da70 ("node: add global mbuf dynfield")

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
---
 lib/node/rte_node_mbuf_dynfield.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lib/node/rte_node_mbuf_dynfield.h b/lib/node/rte_node_mbuf_dynfield.h
index b77fdbb94f..35674ca263 100644
--- a/lib/node/rte_node_mbuf_dynfield.h
+++ b/lib/node/rte_node_mbuf_dynfield.h
@@ -26,12 +26,13 @@ extern "C" {

 #ifndef RTE_NODE_MBUF_PERSISTENT_FIELDS_SIZE
 /** Size of persistent mbuf fields */
-#define RTE_NODE_MBUF_PERSISTENT_FIELDS_SIZE          (0)
+#define RTE_NODE_MBUF_PERSISTENT_FIELDS_SIZE      (1)  /* Must be non-zero to avoid a zero-sized
+                                                        * union, which causes C++ compat issues*/
 #endif /* !RTE_NODE_MBUF_PERSISTENT_FIELDS_SIZE */

 #ifndef RTE_NODE_MBUF_OVERLOADABLE_FIELDS_SIZE
 /** Size of overloadable mbuf fields */
-#define RTE_NODE_MBUF_OVERLOADABLE_FIELDS_SIZE        (8)
+#define RTE_NODE_MBUF_OVERLOADABLE_FIELDS_SIZE   (8)
 #endif /* !RTE_NODE_MBUF_OVERLOADABLE_FIELDS_SIZE */

 /** Size of node mbuf dynamic field */
--
2.48.1


                 reply	other threads:[~2025-06-30 10:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250630104939.2265866-2-bruce.richardson@intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).