[dpdk-dev] [PATCHv2] headers: typeof -> __typeof__ to unbreak C++11 code

Konstantin Ananyev konstantin.ananyev at intel.com
Fri Mar 6 16:59:47 CET 2015


v2:
Instead of changing all the affected files,
define 'typeofi' and 'asm' if needed.

When compiling C++11-code or above (--std=c++11), the build fails with
lots of

  rte_eth_ctrl.h:517:3: note: in expansion of macro RTE_ALIGN
    (RTE_ALIGN(RTE_ETH_FLOW_MAX, UINT32_BIT)/UINT32_BIT)
    ^

When reading the GCC info pages, I get the feeling that __typeof__ is
a better choice, and that indeed works when including the headers in
C++ files (--std=c++11).

There are some typeof()s left in C files, the patch only touches the
public API.

Signed-off-by: Simon Kagstrom <simon.kagstrom at netinsight.net>
Signed-off-by: Konstantin Ananyev <konstantin.ananyev at intel.com>
---
 lib/librte_eal/common/include/rte_common.h | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index 8ac940c..1867692 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -51,6 +51,15 @@ extern "C" {
 #include <errno.h>
 #include <limits.h>
 
+#ifndef typeof
+#define typeof __typeof__
+#endif
+
+#ifndef asm
+#define asm __asm__
+#endif
+
+
 /*********** Macros to eliminate unused variable warnings ********/
 
 /**
-- 
1.8.5.3



More information about the dev mailing list