Typedefs to anonymous structs creates problems for C++ programs:
GCC:
warning: ‘odp_crypto_op_params’ has a field ‘odp_crypto_op_params::pkt’
whose type uses the anonymous namespace
error: anonymous type with no linkage used to declare function
‘<anonymous struct>* ppp_packet::get_queue() const’ with linkage
CLANG:
extern odp_pool_t tmo_pool;
warning: variable 'tmo_pool' has internal linkage but is not defined
When linking:
undefined reference to `tmo_pool'

The solution is to add a (unique) name to all structs used by the strong
typing typedefs.

Signed-off-by: Ola Liljedahl <ola.liljed...@linaro.org>
---
(This document/code contribution attached is provided under the terms of
agreement LES-LTM-21309)

 platform/linux-generic/include/odp/plat/buffer_types.h         | 4 ++--
 platform/linux-generic/include/odp/plat/classification_types.h | 8 ++++----
 platform/linux-generic/include/odp/plat/crypto_types.h         | 2 +-
 platform/linux-generic/include/odp/plat/event_types.h          | 2 +-
 platform/linux-generic/include/odp/plat/packet_io_types.h      | 2 +-
 platform/linux-generic/include/odp/plat/packet_types.h         | 4 ++--
 platform/linux-generic/include/odp/plat/pool_types.h           | 2 +-
 platform/linux-generic/include/odp/plat/queue_types.h          | 4 ++--
 platform/linux-generic/include/odp/plat/shared_memory_types.h  | 2 +-
 platform/linux-generic/include/odp/plat/strong_types.h         | 6 +++++-
 10 files changed, 20 insertions(+), 16 deletions(-)

diff --git a/platform/linux-generic/include/odp/plat/buffer_types.h 
b/platform/linux-generic/include/odp/plat/buffer_types.h
index 3e7070e..0c017ae 100644
--- a/platform/linux-generic/include/odp/plat/buffer_types.h
+++ b/platform/linux-generic/include/odp/plat/buffer_types.h
@@ -26,13 +26,13 @@ extern "C" {
  */
 
 /** ODP buffer */
-typedef odp_handle_t odp_buffer_t;
+typedef ODP_HANDLE_T(odp_buffer_t);
 
 /** Invalid buffer */
 #define ODP_BUFFER_INVALID _odp_cast_scalar(odp_buffer_t, 0xffffffff)
 
 /** ODP buffer segment */
-typedef odp_handle_t odp_buffer_seg_t;
+typedef ODP_HANDLE_T(odp_buffer_seg_t);
 
 /** Invalid segment */
 #define ODP_SEGMENT_INVALID ((odp_buffer_seg_t)ODP_BUFFER_INVALID)
diff --git a/platform/linux-generic/include/odp/plat/classification_types.h 
b/platform/linux-generic/include/odp/plat/classification_types.h
index 042d8c8..767da7d 100644
--- a/platform/linux-generic/include/odp/plat/classification_types.h
+++ b/platform/linux-generic/include/odp/plat/classification_types.h
@@ -23,18 +23,18 @@ extern "C" {
  *  @{
  */
 
-typedef odp_handle_t odp_cos_t;
-typedef odp_handle_t odp_flowsig_t;
+typedef ODP_HANDLE_T(odp_cos_t);
+typedef ODP_HANDLE_T(odp_flowsig_t);
 
 #define ODP_COS_INVALID  _odp_cast_scalar(odp_cos_t, ~0)
 #define ODP_COS_NAME_LEN 32
 
 typedef uint16_t odp_cos_flow_set_t;
 
-typedef odp_handle_t odp_pmr_t;
+typedef ODP_HANDLE_T(odp_pmr_t);
 #define ODP_PMR_INVAL _odp_cast_scalar(odp_pmr_t, ~0)
 
-typedef odp_handle_t odp_pmr_set_t;
+typedef ODP_HANDLE_T(odp_pmr_set_t);
 #define ODP_PMR_SET_INVAL _odp_cast_scalar(odp_pmr_set_t, ~0)
 
 /** Get printable format of odp_cos_t */
diff --git a/platform/linux-generic/include/odp/plat/crypto_types.h 
b/platform/linux-generic/include/odp/plat/crypto_types.h
index 1b10a5d..a91d88e 100644
--- a/platform/linux-generic/include/odp/plat/crypto_types.h
+++ b/platform/linux-generic/include/odp/plat/crypto_types.h
@@ -25,7 +25,7 @@ extern "C" {
 #define ODP_CRYPTO_SESSION_INVALID (0xffffffffffffffffULL)
 
 typedef uint64_t odp_crypto_session_t;
-typedef odp_handle_t odp_crypto_compl_t;
+typedef ODP_HANDLE_T(odp_crypto_compl_t);
 
 enum odp_crypto_op_mode {
        ODP_CRYPTO_SYNC,
diff --git a/platform/linux-generic/include/odp/plat/event_types.h 
b/platform/linux-generic/include/odp/plat/event_types.h
index 24be22f..d91937d 100644
--- a/platform/linux-generic/include/odp/plat/event_types.h
+++ b/platform/linux-generic/include/odp/plat/event_types.h
@@ -26,7 +26,7 @@ extern "C" {
  *  @{
  */
 
-typedef odp_handle_t odp_event_t;
+typedef ODP_HANDLE_T(odp_event_t);
 
 #define ODP_EVENT_INVALID _odp_cast_scalar(odp_event_t, 0xffffffff)
 
diff --git a/platform/linux-generic/include/odp/plat/packet_io_types.h 
b/platform/linux-generic/include/odp/plat/packet_io_types.h
index 60592e3..3cc64c6 100644
--- a/platform/linux-generic/include/odp/plat/packet_io_types.h
+++ b/platform/linux-generic/include/odp/plat/packet_io_types.h
@@ -26,7 +26,7 @@ extern "C" {
  *  @{
  */
 
-typedef odp_handle_t odp_pktio_t;
+typedef ODP_HANDLE_T(odp_pktio_t);
 
 #define ODP_PKTIO_INVALID _odp_cast_scalar(odp_pktio_t, 0)
 
diff --git a/platform/linux-generic/include/odp/plat/packet_types.h 
b/platform/linux-generic/include/odp/plat/packet_types.h
index 57e9662..45cb801 100644
--- a/platform/linux-generic/include/odp/plat/packet_types.h
+++ b/platform/linux-generic/include/odp/plat/packet_types.h
@@ -26,13 +26,13 @@ extern "C" {
  *  @{
  */
 
-typedef odp_handle_t odp_packet_t;
+typedef ODP_HANDLE_T(odp_packet_t);
 
 #define ODP_PACKET_INVALID _odp_cast_scalar(odp_packet_t, 0xffffffff)
 
 #define ODP_PACKET_OFFSET_INVALID (0x0fffffff)
 
-typedef odp_handle_t odp_packet_seg_t;
+typedef ODP_HANDLE_T(odp_packet_seg_t);
 
 #define ODP_PACKET_SEG_INVALID _odp_cast_scalar(odp_packet_seg_t, 0xffffffff)
 
diff --git a/platform/linux-generic/include/odp/plat/pool_types.h 
b/platform/linux-generic/include/odp/plat/pool_types.h
index 71c7783..568556f 100644
--- a/platform/linux-generic/include/odp/plat/pool_types.h
+++ b/platform/linux-generic/include/odp/plat/pool_types.h
@@ -25,7 +25,7 @@ extern "C" {
  *  @{
  */
 
-typedef odp_handle_t odp_pool_t;
+typedef ODP_HANDLE_T(odp_pool_t);
 
 #define ODP_POOL_INVALID _odp_cast_scalar(odp_pool_t, 0xffffffff)
 
diff --git a/platform/linux-generic/include/odp/plat/queue_types.h 
b/platform/linux-generic/include/odp/plat/queue_types.h
index 04a0be9..1cecc90 100644
--- a/platform/linux-generic/include/odp/plat/queue_types.h
+++ b/platform/linux-generic/include/odp/plat/queue_types.h
@@ -25,9 +25,9 @@ extern "C" {
  *  @{
  */
 
-typedef odp_handle_t odp_queue_t;
+typedef ODP_HANDLE_T(odp_queue_t);
 
-typedef odp_handle_t odp_queue_group_t;
+typedef ODP_HANDLE_T(odp_queue_group_t);
 
 #define ODP_QUEUE_INVALID  _odp_cast_scalar(odp_queue_t, 0)
 
diff --git a/platform/linux-generic/include/odp/plat/shared_memory_types.h 
b/platform/linux-generic/include/odp/plat/shared_memory_types.h
index d2e92cf..4be7356 100644
--- a/platform/linux-generic/include/odp/plat/shared_memory_types.h
+++ b/platform/linux-generic/include/odp/plat/shared_memory_types.h
@@ -26,7 +26,7 @@ extern "C" {
  *  @{
  */
 
-typedef odp_handle_t odp_shm_t;
+typedef ODP_HANDLE_T(odp_shm_t);
 
 #define ODP_SHM_INVALID _odp_cast_scalar(odp_shm_t, 0)
 #define ODP_SHM_NULL ODP_SHM_INVALID
diff --git a/platform/linux-generic/include/odp/plat/strong_types.h 
b/platform/linux-generic/include/odp/plat/strong_types.h
index cd15853..39bdea3 100644
--- a/platform/linux-generic/include/odp/plat/strong_types.h
+++ b/platform/linux-generic/include/odp/plat/strong_types.h
@@ -16,7 +16,11 @@
 #define STRONG_TYPES_H_
 
 /** Use strong typing for ODP types */
-#define odp_handle_t struct { uint8_t unused_dummy_var; } *
+#ifdef __cplusplus
+#define ODP_HANDLE_T(type) struct _##type { uint8_t unused_dummy_var; } *type
+#else
+#define ODP_HANDLE_T(type) struct { } *type
+#endif
 
 /** Internal macro to get value of an ODP handle */
 #define _odp_typeval(handle) ((uint32_t)(uintptr_t)(handle))
-- 
1.9.1


_______________________________________________
lng-odp mailing list
lng-odp@lists.linaro.org
http://lists.linaro.org/mailman/listinfo/lng-odp

Reply via email to