NetworkManager/src/libnm-client-public/nm-object.h
Thomas Haller 5cc31b79dd
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')
2022-05-12 15:47:57 +02:00

43 lines
1.2 KiB
C

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2007 - 2008 Novell, Inc.
* Copyright (C) 2007 - 2012 Red Hat, Inc.
*/
#ifndef __NM_OBJECT_H__
#define __NM_OBJECT_H__
#if !defined(__NETWORKMANAGER_H_INSIDE__) && !defined(NETWORKMANAGER_COMPILATION)
#error "Only <NetworkManager.h> can be included directly."
#endif
G_BEGIN_DECLS
#define NM_TYPE_OBJECT (nm_object_get_type())
#define NM_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), NM_TYPE_OBJECT, NMObject))
#define NM_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), NM_TYPE_OBJECT, NMObjectClass))
#define NM_IS_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), NM_TYPE_OBJECT))
#define NM_IS_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), NM_TYPE_OBJECT))
#define NM_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), NM_TYPE_OBJECT, NMObjectClass))
#define NM_OBJECT_PATH "path"
#define NM_OBJECT_CLIENT "client"
/**
* NMObject:
*/
typedef struct _NMObject NMObject;
typedef struct _NMObjectClass NMObjectClass;
GType nm_object_get_type(void);
const char *nm_object_get_path(NMObject *object);
struct _NMClient;
NM_AVAILABLE_IN_1_24
struct _NMClient *nm_object_get_client(NMObject *object);
G_END_DECLS
#endif /* __NM_OBJECT_H__ */