Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 441
user8063157 Avatar asked Jan 02 '23 05:01

user8063157


1 Answers

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

like image 108
lubgr Avatar answered Jan 08 '23 23:01

lubgr