[dpdk-dev,3/3] mbuf_offload: fix header for C++

Message ID 1454691969-25734-4-git-send-email-thomas.monjalon@6wind.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Commit Message

Thomas Monjalon Feb. 5, 2016, 5:06 p.m. UTC
  When built in a C++ application, the include fails for 2 reasons:

rte_mbuf_offload.h:128:24: error:
invalid conversion from ‘void*’ to ‘rte_pktmbuf_offload_pool_private*’ [-fpermissive]
    rte_mempool_get_priv(mpool);
                        ^

rte_mbuf_offload.h:304:1: error: expected declaration before ‘}’ token

Fixes: 78c8709b5ddb ("mbuf_offload: introduce library to attach offloads to mbuf")

Signed-off-by: Thomas Monjalon <thomas.monjalon@6wind.com>
---
 lib/librte_mbuf_offload/rte_mbuf_offload.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
  

Comments

Thomas Monjalon Feb. 5, 2016, 9:33 p.m. UTC | #1
2016-02-05 18:06, Thomas Monjalon:
> When built in a C++ application, the include fails for 2 reasons:
> 
> rte_mbuf_offload.h:128:24: error:
> invalid conversion from ‘void*’ to ‘rte_pktmbuf_offload_pool_private*’ [-fpermissive]
>     rte_mempool_get_priv(mpool);
>                         ^
[...]
>  	struct rte_pktmbuf_offload_pool_private *priv =
> -			rte_mempool_get_priv(mpool);
> +		(rte_pktmbuf_offload_pool_private *)rte_mempool_get_priv(mpool);

self-nack: a struct keyword is missing
  

Patch

diff --git a/lib/librte_mbuf_offload/rte_mbuf_offload.h b/lib/librte_mbuf_offload/rte_mbuf_offload.h
index 4345f06..a0e990d 100644
--- a/lib/librte_mbuf_offload/rte_mbuf_offload.h
+++ b/lib/librte_mbuf_offload/rte_mbuf_offload.h
@@ -59,6 +59,9 @@ 
 #include <rte_mbuf.h>
 #include <rte_crypto.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 
 /** packet mbuf offload operation types */
 enum rte_mbuf_ol_op_type {
@@ -125,7 +128,7 @@  static inline uint16_t
 __rte_pktmbuf_offload_priv_size(struct rte_mempool *mpool)
 {
 	struct rte_pktmbuf_offload_pool_private *priv =
-			rte_mempool_get_priv(mpool);
+		(rte_pktmbuf_offload_pool_private *)rte_mempool_get_priv(mpool);
 
 	return priv->offload_priv_size;
 }