3

I need to put namespace prefix in macros. I.e.

#define MYMACRO(x) ....##x

namespace A {
  namespace B {
    MYMACRO(C);
  }
}

and MYMACRO must return - A::B::C?

3

1 Answer 1

6

Can't work. Namespaces are recognized by the compiler, which runs only after the preprocessor.

2
  • 1
    That's the right answer. And it might lead to a solution: If you need something to be seen by the preprocessor, put it there. Before namespace A, put a #define OUTERNAMESPACE A, before B define INNERNAMESPACE B. How that would be better than just writing it manually I don't know.
    – starmole
    Feb 14, 2014 at 10:13
  • @starmole: Well, it would be called "writing it manually twice" :) Feb 14, 2014 at 10:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.