首页 > 解决方案 > Restrict namespace pollution in C++ Header

问题描述

In our team we want to Restrict practice of adding "using namespace" in header at global scope as that is not a good practice and often leads to name collision and namespace pollution.

Is there a way in gcc we can restrict this practice of adding using namespace in header at compile time?

I mean to get some kind of warning when the compiler sees at global scope in header "using namespace".

Thanks

标签: c++gccnamespaces

解决方案


You can use clang-tidy together with the google build using namespace check, which should complain on these using directives.


推荐阅读