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.
This commit is contained in:
@@ -20,6 +20,14 @@
|
|||||||
#ifndef __NM_GLIB_H__
|
#ifndef __NM_GLIB_H__
|
||||||
#define __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 <gio/gio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user