+static void PRINTF_FORMAT (2, 3)
+macro_error (const struct macro_expansion_stack *stack,
+ const char *format, ...)
+{
+ va_list args;
+ va_start (args, format);
+ char *s = xvasprintf (format, args);
+ va_end (args);
+
+ /* foo.sps:12: While expanding macro 'innermost',
+ foo.sps:23: inside expansion of 'next_inner',
+ foo.sps:34: inside expansion of 'next_inner2',
+ foo.sps:45: inside expansion of 'outermost':
+ error. */
+ struct string header = DS_EMPTY_INITIALIZER;
+ ds_put_format (&header, "While expanding \"%s\"", stack->name);
+ while ((stack = stack->next) != NULL)
+ ds_put_format (&header, ", inside expansion of \"%s\"", stack->name);
+
+ msg (SE, "%s: %s", ds_cstr (&header), s);
+
+ ds_destroy (&header);
+ free (s);
+}
+