Fix: python: suppress -Wmissing-prototypes warning with SWIG 3.0.10
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 27 Mar 2020 01:11:35 +0000 (21:11 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 3 Apr 2020 21:52:33 +0000 (17:52 -0400)
SWIG 3.0.10 is used on SLES 12.  It produces this warning:

      CC       lttng_wrap.lo
    lttng_wrap.c:3411:1: error: no previous prototype for ‘SWIG_strnlen’ [-Werror=missing-prototypes]
     3411 | SWIG_strnlen(const char* s, size_t maxlen)
          | ^~~~~~

SWIG_strnlen is defined like this:

    size_t
    SWIG_strnlen(const char* s, size_t maxlen)
    {
        ...
    }

Since the function is not static and has no previous declaration, the
diagnostic is emitted.  We can see that they have fixed it in SWIG
3.0.12, where the same function is defined as:

    SWIGINTERN size_t
    SWIG_strnlen(const char* s, size_t maxlen)
    {
        ...
    }

SWIGINTERN is defined as static.

We can workaround the warning by adding our own declaration for
SWIG_strnlen in lttng.i(.in).

Tested by build with SWIG 3.0.10, 3.0.11 and 3.0.12.

Change-Id: I7d9d93cf5fc04f2044a47ad384e16d726e27f72f
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
extras/bindings/swig/python/lttng.i.in

index b6b6f960eba7720955611e3adbeceaa3679195e2..684482e1fd2c06605e64ad2cc91e10f55887847f 100644 (file)
@@ -32,6 +32,11 @@ multiple concurrent processes and threads. Tracing across multiple systems is al
 
 // Avoid -Wmissing-declarations warning.
 PyObject *SWIG_init(void);
+
+// Avoid -Wmissing-prototypes warning with SWIG 3.0.10.
+#if SWIG_VERSION < 0x30012
+static size_t SWIG_strnlen(const char* s, size_t maxlen);
+#endif
 %}
 
 typedef unsigned int uint32_t;
This page took 0.025464 seconds and 4 git commands to generate.