libnm: avoid duplicate typedefs for NMClient/NMDevice

clang 3.4.2-9.el7 does not like this:

  $ clang -DHAVE_CONFIG_H -I. -I..  -I../src/libnm-core-public -I./src/libnm-core-public -I../src/libnm-client-public -I./src/libnm-client-public -pthread -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include   -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_40  -Wall -Werror -Wextra -Wdeclaration-after-statement -Wfloat-equal -Wformat-nonliteral -Wformat-security -Wimplicit-function-declaration -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes -Wpointer-arith -Wshadow -Wstrict-prototypes -Wundef -Wvla -Wno-duplicate-decl-specifier -Wno-format-y2k -Wno-missing-field-initializers -Wno-sign-compare -Wno-tautological-constant-out-of-range-compare -Wno-unknown-pragmas -Wno-unused-parameter  -Qunused-arguments -Wunknown-warning-option -Wtypedef-redefinition -Warray-bounds -Wparentheses-equality -Wunused-value -Wimplicit-fallthrough  -fno-strict-aliasing -fdata-sections -ffunction-sections -Wl,--gc-sections -g -O2 -MT examples/C/glib/examples_C_glib_add_connection_libnm-add-connection-libnm.o -MD -MP -MF examples/C/glib/.deps/examples_C_glib_add_connection_libnm-add-connection-libnm.Tpo -c -o examples/C/glib/examples_C_glib_add_connection_libnm-add-connection-libnm.o `test -f 'examples/C/glib/add-connection-libnm.c' || echo '../'`examples/C/glib/add-connection-libnm.c
  ...
  ../src/libnm-client-public/nm-client.h:149:31: error: redefinition of typedef 'NMClient' is a C11 feature [-Werror,-Wtypedef-redefinition]
  typedef struct _NMClient      NMClient;
                                ^

Our code base is C11 internally (actually "-std=gnu11"), but this problem
happens when we build the example. The warning is actually correct, because
our public headers should be more liberal (and possibly be C99 or even C89,
this is undefined).

Fixes: 649314ddaa ('libnm: replace nm-types.h by defining the types in respective headers')
This commit is contained in:
Thomas Haller
2022-05-11 17:37:03 +02:00
parent 7de0ba4199
commit 5cc31b79dd
2 changed files with 15 additions and 13 deletions

View File

@@ -43,8 +43,6 @@ G_BEGIN_DECLS
#define NM_ACTIVE_CONNECTION_VPN "vpn"
#define NM_ACTIVE_CONNECTION_MASTER "master"
typedef struct _NMDevice NMDevice;
/**
* NMActiveConnection:
*/
@@ -64,7 +62,11 @@ NM_AVAILABLE_IN_1_10
NMActivationStateFlags nm_active_connection_get_state_flags(NMActiveConnection *connection);
NM_AVAILABLE_IN_1_8
NMActiveConnectionStateReason nm_active_connection_get_state_reason(NMActiveConnection *connection);
NMDevice *nm_active_connection_get_master(NMActiveConnection *connection);
struct _NMDevice;
struct _NMDevice *nm_active_connection_get_master(NMActiveConnection *connection);
gboolean nm_active_connection_get_default(NMActiveConnection *connection);
NMIPConfig *nm_active_connection_get_ip4_config(NMActiveConnection *connection);
NMDhcpConfig *nm_active_connection_get_dhcp4_config(NMActiveConnection *connection);

View File

@@ -23,8 +23,6 @@ G_BEGIN_DECLS
#define NM_OBJECT_PATH "path"
#define NM_OBJECT_CLIENT "client"
typedef struct _NMClient NMClient;
/**
* NMObject:
*/
@@ -35,8 +33,10 @@ GType nm_object_get_type(void);
const char *nm_object_get_path(NMObject *object);
struct _NMClient;
NM_AVAILABLE_IN_1_24
NMClient *nm_object_get_client(NMObject *object);
struct _NMClient *nm_object_get_client(NMObject *object);
G_END_DECLS