[dpdk-dev,12/13] ethdev: fix C++ errors in flow API (MPLS, GRE)
Checks
Commit Message
This commit addresses the following compilation errors:
In file included from build/include/rte_flow_driver.h:50:0,
from /tmp/check-includes.sh.1397.cc:1:
build/include/rte_flow.h:631:1: error: C99 designator 'label_tc_s' outside
aggregate initializer
[...]
build/include/rte_flow.h:631:1: error: initializer-string for array of
chars is too long [-fpermissive]
[...]
build/include/rte_flow.h:650:1: sorry, unimplemented: non-trivial
designated initializers not supported
[...]
C++ does not support the C99-style designated initializers used in this
file for the default item masks. While the resulting symbols are primarily
useful to PMDs (written in C), they are exposed as part of the public API
for documentation purposes and to assist application writers.
Considering that:
- using pre-C99 initialization style for compatibility with C++ would
render them difficult to understand (all struct members must be
initialized)
- using both initialization styles would be needlessly verbose
- not exposing them at all would defeat their purpose
- applications do not normally need these symbols at run time
This commit hides these symbols from C++ applications. Specific C++
initializers will be added later if necessary.
Fixes: 7cd048321d1d ("ethdev: add MPLS and GRE flow API items")
Cc: Beilei Xing <beilei.xing@intel.com>
Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
---
lib/librte_ether/rte_flow.h | 4 ++++
1 file changed, 4 insertions(+)
Comments
> -----Original Message-----
> From: Adrien Mazarguil [mailto:adrien.mazarguil@6wind.com]
> Sent: Monday, April 24, 2017 11:53 PM
> To: dev@dpdk.org
> Cc: Xing, Beilei <beilei.xing@intel.com>
> Subject: [PATCH 12/13] ethdev: fix C++ errors in flow API (MPLS, GRE)
>
> This commit addresses the following compilation errors:
>
> In file included from build/include/rte_flow_driver.h:50:0,
> from /tmp/check-includes.sh.1397.cc:1:
> build/include/rte_flow.h:631:1: error: C99 designator 'label_tc_s' outside
> aggregate initializer
> [...]
> build/include/rte_flow.h:631:1: error: initializer-string for array of
> chars is too long [-fpermissive]
> [...]
> build/include/rte_flow.h:650:1: sorry, unimplemented: non-trivial
> designated initializers not supported [...]
>
> C++ does not support the C99-style designated initializers used in this
> file for the default item masks. While the resulting symbols are primarily useful
> to PMDs (written in C), they are exposed as part of the public API for
> documentation purposes and to assist application writers.
>
> Considering that:
>
> - using pre-C99 initialization style for compatibility with C++ would
> render them difficult to understand (all struct members must be
> initialized)
> - using both initialization styles would be needlessly verbose
> - not exposing them at all would defeat their purpose
> - applications do not normally need these symbols at run time
>
> This commit hides these symbols from C++ applications. Specific C++ initializers
> will be added later if necessary.
>
> Fixes: 7cd048321d1d ("ethdev: add MPLS and GRE flow API items")
>
> Cc: Beilei Xing <beilei.xing@intel.com>
> Signed-off-by: Adrien Mazarguil <adrien.mazarguil@6wind.com>
> ---
> lib/librte_ether/rte_flow.h | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/lib/librte_ether/rte_flow.h b/lib/librte_ether/rte_flow.h index
> bc7bc45..abd4c6a 100644
> --- a/lib/librte_ether/rte_flow.h
> +++ b/lib/librte_ether/rte_flow.h
> @@ -652,9 +652,11 @@ struct rte_flow_item_mpls { };
>
> /** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
> +#ifndef __cplusplus
> static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
> .label_tc_s = "\xff\xff\xf0",
> };
> +#endif
>
> /**
> * RTE_FLOW_ITEM_TYPE_GRE.
> @@ -671,9 +673,11 @@ struct rte_flow_item_gre { };
>
> /** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
> +#ifndef __cplusplus
> static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
> .protocol = 0xffff,
> };
> +#endif
>
> /**
> * Matching pattern item definition.
> --
> 2.1.4
Acked-by: Beilei Xing <beilei.xing@intel.com>
Thanks.
@@ -652,9 +652,11 @@ struct rte_flow_item_mpls {
};
/** Default mask for RTE_FLOW_ITEM_TYPE_MPLS. */
+#ifndef __cplusplus
static const struct rte_flow_item_mpls rte_flow_item_mpls_mask = {
.label_tc_s = "\xff\xff\xf0",
};
+#endif
/**
* RTE_FLOW_ITEM_TYPE_GRE.
@@ -671,9 +673,11 @@ struct rte_flow_item_gre {
};
/** Default mask for RTE_FLOW_ITEM_TYPE_GRE. */
+#ifndef __cplusplus
static const struct rte_flow_item_gre rte_flow_item_gre_mask = {
.protocol = 0xffff,
};
+#endif
/**
* Matching pattern item definition.