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?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Yola
  • 18,496
  • 11
  • 65
  • 106

1 Answers1

6

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

MSalters
  • 173,980
  • 10
  • 155
  • 350
  • 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 '14 at 10:13
  • @starmole: Well, it would be called "writing it manually twice" :) – Lightness Races in Orbit Feb 14 '14 at 10:21