Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

One of the vagaries of my development system (Codegear C++Builder) is that some of the auto-generated headers insist on having...

using namespace xyzzy

...statements in them, which impact on my code when I least want or expect it.

Is there a way I can somehow cancel/override a previous "using" statement to avoid this.

Maybe...

unusing namespace xyzzy;
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
286 views
Welcome To Ask or Share your Answers For Others

1 Answer

Nope. But there's a potential solution: if you enclose your include directive in a namespace of its own, like this...

namespace codegear {
    #include "codegear_header.h"
} // namespace codegear

...then the effects of any using directives within that header are neutralized.

That might be problematic in some cases. That's why every C++ style guide strongly recommends not putting a "using namespace" directive in a header file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...