, , , , , Google .
, , #define #undef .
:
#include "header1"
#define shortNS test::test1
namespace test2 {
class Test1 {
void test(shortNS::test &test) {}
void test1(shortNS::test &test) {}
void test2(shortNS::test &test1, shortNS::test &test2) {}
};
}
#undef shortNS
, , "shortNS", "test:: test1", . , , - , , , , .
, , we #undef shortNS, "shortNS" "test:: test1". . shortNS "" .
.
:
- . ( ?).
- , .
- "namespace a = b:: c"
- "using namespace"
- (, "using namespace" )
:
- , .
- #define #undef, , / .
- #undef, / , .
- .
- , , .
In short, if you like macros and don't mind pulling your hair out, trying to debug it when it goes wrong, go ahead. A preprocessor is a very, very powerful thing, but as if sticking a little C4 on your foot and crushing the keyboard to set a timer, you don’t know when it is going to knock your foot out.
source
share