From 18080960e1f85bb315d927d18e52656973834813 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Fri, 16 Dec 2016 13:43:54 +0100 Subject: utils.h: add OSMO_STRINGIFY and OSMO_VALUE_STRING macros OSMO_STRINGIFY particularly allows putting port numbers from a #define into VTY doc strings, like: #define FOO_PORT 2342 DEFUN(..., "Foo UDP port (default: " OSMO_STRINGIFY(FOO_PORT) ")\n") OSMO_VALUE_STRING creates value_string items with the string being exactly the enum value's name. Replaces a similar macro def in fsm.c Change-Id: I857af45ae602bb9a647ba26cf8b0d1b23403b54c --- include/osmocom/core/utils.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h index 3c6fc98e..41bbc279 100644 --- a/include/osmocom/core/utils.h +++ b/include/osmocom/core/utils.h @@ -15,6 +15,10 @@ #define OSMO_MAX(a, b) ((a) >= (b) ? (a) : (b)) /*! \brief Return the minimum of two specified values */ #define OSMO_MIN(a, b) ((a) >= (b) ? (b) : (a)) +/*! \brief Stringify the contents of a macro, e.g. a port number */ +#define OSMO_STRINGIFY(x) #x +/*! \brief Make a value_string entry from an enum value name */ +#define OSMO_VALUE_STRING(x) { x, OSMO_STRINGIFY(x) } #include -- cgit v1.2.3