Andrei G has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/43572?usp=email )


Change subject: core/stats_tcp: declare struct osmo_fd in header
......................................................................

core/stats_tcp: declare struct osmo_fd in header

include/osmocom/core/stats_tcp.h names struct osmo_fd in its prototypes
without declaring it and without including select.h. A translation unit
that includes stats_tcp.h on its own therefore gives the type function
prototype scope, and a later definition of one of those functions in the
same unit has a different, incompatible type. Clang reports -Wvisibility
and then rejects the definitions outright.

Every in-tree caller happens to include select.h first, which is why this
never showed up. It surfaced while writing a Darwin implementation of the
same functions, where stats_tcp.h is the only include.

Add the forward declaration to the header rather than requiring each
includer to get the order right. A forward declaration is enough: the
prototypes take a pointer. Nothing here is platform specific and there is
no runtime impact.

Change-Id: I2f31f45317e6a28f47470ba6a5e4a31e4704e831
Signed-off-by: Andrei Gosman <[email protected]>
---
M include/osmocom/core/stats_tcp.h
1 file changed, 6 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/72/43572/1

diff --git a/include/osmocom/core/stats_tcp.h b/include/osmocom/core/stats_tcp.h
index 9bc7111..759dc3b 100644
--- a/include/osmocom/core/stats_tcp.h
+++ b/include/osmocom/core/stats_tcp.h
@@ -11,6 +11,12 @@
 };
 extern struct osmo_tcp_stats_config *osmo_tcp_stats_config;

+/* The prototypes below name struct osmo_fd without declaring it. A translation
+ * unit that includes this header on its own therefore gives the type function
+ * prototype scope, and a later definition of one of these functions is a
+ * different type. Declare it here instead of relying on the includer. */
+struct osmo_fd;
+
 int osmo_stats_tcp_osmo_fd_register(const struct osmo_fd *fd, const char 
*name);
 int osmo_stats_tcp_osmo_fd_unregister(const struct osmo_fd *fd);
 int osmo_stats_tcp_set_interval(int interval);

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/43572?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I2f31f45317e6a28f47470ba6a5e4a31e4704e831
Gerrit-Change-Number: 43572
Gerrit-PatchSet: 1
Gerrit-Owner: Andrei G <[email protected]>

Reply via email to