It looks like inside the macro message SET_NONEMPTY(foobar) you expect set_##x_for_serving to expand to set_foobar_for_serving .
Is it correct?
If so, the phrase x_for_serving represents a single token, and x will not be considered by the preprocessor as an element for replacement.
I think you want set_##x##_for_serving instead:
#define SET_NONEMPTY(x) { const NString& var = r->hdrs->get_##x(); \ if (!var.empty()) { \ set_##x##_for_serving(r->request, var.data(), var.length()); \ } \ }
source share