mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-04 09:28:00 +02:00
macros: define NM_MORE_ASSERTS is not defined
In NetworkManager's configure script we have --with-more-asserts option which always defines NM_MORE_ASSERTS in config.h. When reusing the header file outside of NetworkManager, the NM_MORE_ASSERTS define might be unset. Define it in that case to avoid compiler warnings about undefined preprocessor define.
This commit is contained in:
parent
dab2d46aa2
commit
b871106e25
1 changed files with 16 additions and 0 deletions
|
|
@ -297,6 +297,22 @@ _NM_IN_STRSET_streq (const char *x, const char *s)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* glib/C provides the following kind of assertions:
|
||||
* - assert() -- disable with NDEBUG
|
||||
* - g_return_if_fail() -- disable with G_DISABLE_CHECKS
|
||||
* - g_assert() -- disable with G_DISABLE_ASSERT
|
||||
* but they are all enabled by default and usually even production builds have
|
||||
* these kind of assertions enabled. It also means, that disabling assertions
|
||||
* is an untested configuration, and might have bugs.
|
||||
*
|
||||
* Add our own assertion macro nm_assert(), which is disabled by default and must
|
||||
* be explicitly enabled. They are useful for more expensive checks or checks that
|
||||
* depend less on runtime conditions (that is, are generally expected to be true). */
|
||||
|
||||
#ifndef NM_MORE_ASSERTS
|
||||
#define NM_MORE_ASSERTS 0
|
||||
#endif
|
||||
|
||||
#if NM_MORE_ASSERTS
|
||||
#define nm_assert(cond) G_STMT_START { g_assert (cond); } G_STMT_END
|
||||
#define nm_assert_not_reached() G_STMT_START { g_assert_not_reached (); } G_STMT_END
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue