summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-07-09 13:46:47 +0200
committerThomas Haller <thaller@redhat.com>2018-07-09 16:30:12 +0200
commitbf593304ef24e04102955f2f535cf0703a8c5989 (patch)
tree08923c4daa23930a02df3fdf26caf01fcc646fcc
parent62cd6afd98186b137915aea78b0883cf9f3cb720 (diff)
downloadNetworkManager-bf593304ef24e04102955f2f535cf0703a8c5989.tar.gz
shared: ensure "nm-glib.h" is not used without "nm-macros-internal.h"
Note how "nm-glib.h" uses _nm_printf() macro, which is defined in "nm-macros-internal.h". There are many ways how to solve that problem. For example, we could define certain _nm_*() macros in "nm-glib.h" itself. However, that is a bit awkward, because optimally "nm-glib.h" only provides functions that are strictly related to glib compatiblity. _nm_printf() is used by "nm-glib.h" for its own implementation, it should not provide (or reimplement) this macro. We solve this instead by enforcing what NetworkManager already does. NetworkManager never includes "nm-glib.h" directly, instead "nm-macros-internal.h" is the only place that includes the glib compat header. It means, you cannot use "nm-glib.h" without "nm-macros-internal.h". But that is a reasonable compromise, with respect to granularity. The granularity at the moment is: if you use anything from "shared/nm-utils", you almost always need at least "nm-macros-internal.h" header (and automatically also get "nm-glib.h" and "gsystem-local-alloc.h"). It's not intended, to use "nm-glib.h" directly. This makes "nm-glib.h" an implementation detail of "nm-macros-internal.h" and it only exists to separate code that is related to glib compatibility to its own header.
-rw-r--r--shared/nm-utils/nm-glib.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/shared/nm-utils/nm-glib.h b/shared/nm-utils/nm-glib.h
index 08ede9e594..fd7865195c 100644
--- a/shared/nm-utils/nm-glib.h
+++ b/shared/nm-utils/nm-glib.h
@@ -20,6 +20,14 @@
#ifndef __NM_GLIB_H__
#define __NM_GLIB_H__
+/*****************************************************************************/
+
+#ifndef __NM_MACROS_INTERNAL_H__
+#error "nm-glib.h requires nm-macros-internal.h. Do not include this directly"
+#endif
+
+/*****************************************************************************/
+
#include <gio/gio.h>
#include <string.h>