From 8b6f2d5dba0b81891d2445685158ed442cc82328 Mon Sep 17 00:00:00 2001 From: Andy Green Date: Fri, 18 Feb 2022 08:25:58 +0000 Subject: [PATCH] gcc4: conceal typedef in public header Modern toolchains are fine with giving a typedef as a forward reference, but gcc 4.3 can't cope with that and then seeing the real definition in the .c later. Just conceal the typedef and use the struct form for the forward reference resolution type in the public header so even senior toolchains are happy. --- include/libwebsockets/lws-map.h | 16 ++++++++-------- .../api-tests/api-test-lws_map/main.c | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/libwebsockets/lws-map.h b/include/libwebsockets/lws-map.h index 4462881be..cf2368a0b 100644 --- a/include/libwebsockets/lws-map.h +++ b/include/libwebsockets/lws-map.h @@ -43,7 +43,7 @@ //@{ typedef struct lws_map lws_map_t; -typedef struct lws_map_item lws_map_item_t; +struct lws_map_item; typedef void * lws_map_key_t; typedef void * lws_map_value_t; @@ -76,13 +76,13 @@ typedef struct lws_map_info { } lws_map_info_t; LWS_VISIBLE LWS_EXTERN const void * -lws_map_item_key(lws_map_item_t *_item); +lws_map_item_key(struct lws_map_item *_item); LWS_VISIBLE LWS_EXTERN const void * -lws_map_item_value(lws_map_item_t *_item); +lws_map_item_value(struct lws_map_item *_item); LWS_VISIBLE LWS_EXTERN size_t -lws_map_item_key_len(lws_map_item_t *_item); +lws_map_item_key_len(struct lws_map_item *_item); LWS_VISIBLE LWS_EXTERN size_t -lws_map_item_value_len(lws_map_item_t *_item); +lws_map_item_value_len(struct lws_map_item *_item); /* * Helpers for C string keys case @@ -158,7 +158,7 @@ lws_map_destroy(lws_map_t **pmap); * creating and adding the new one. */ -LWS_VISIBLE LWS_EXTERN lws_map_item_t * +LWS_VISIBLE LWS_EXTERN struct lws_map_item * lws_map_item_create(lws_map_t *map, const lws_map_key_t key, size_t keylen, const lws_map_value_t value, size_t valuelen); @@ -169,7 +169,7 @@ lws_map_item_create(lws_map_t *map, * \param item: the item in the map to remove and free */ LWS_VISIBLE LWS_EXTERN void -lws_map_item_destroy(lws_map_item_t *item); +lws_map_item_destroy(struct lws_map_item *item); /** * lws_map_item_lookup() - look for a item with the given key in the map @@ -182,7 +182,7 @@ lws_map_item_destroy(lws_map_item_t *item); * functions. */ -LWS_VISIBLE LWS_EXTERN lws_map_item_t * +LWS_VISIBLE LWS_EXTERN struct lws_map_item * lws_map_item_lookup(lws_map_t *map, const lws_map_key_t key, size_t keylen); //@} diff --git a/minimal-examples/api-tests/api-test-lws_map/main.c b/minimal-examples/api-tests/api-test-lws_map/main.c index 022c98a84..c17be8188 100644 --- a/minimal-examples/api-tests/api-test-lws_map/main.c +++ b/minimal-examples/api-tests/api-test-lws_map/main.c @@ -11,6 +11,8 @@ #include +typedef struct lws_map_item lws_map_item_t; + /* custom key and comparator for test 3 */ typedef struct mykey {