C Macro - was not declared in this scope error -


#define set_nonempty(x) { const nstring& var = r->hdrs->get_##x(); \   if (!var.empty()) { \     set_##x_for_serving(r->request, var.data(), var.length()); \   } \ } 

the above macro tries set request member if not empty, following error: 'set_x_for_serving' not declared in scope while use macro.

what wrong in above macro?

you need token-pasting operator on both sides of x in order substitute correctly.

#define set_nonempty(x) { const nstring& var = r->hdrs->get_##x(); \   if (!var.empty()) { \     set_##x##_for_serving(r->request, var.data(), var.length()); \   } \ } 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -