c++ - 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
解决方案
You can use clang-tidy
together with the google build using namespace check, which should complain on these using directives.
推荐阅读
- python - 如何通过使用 while 循环和 if 语句再次输入我的输入?
- kotlin - 有没有办法将 $ 添加到我的打印列表中的每个整数?
- javascript - 如何更改 IndexedDB 索引中对象的值?
- android - 如何将“停止媒体播放器”添加到导航返回按钮
- bash - 如何压缩 ZIP 内没有子目录的文件?
- react-native - 将 openDrawer() 添加到 React Native 中标题上的汉堡菜单 - 导致错误未定义
- r - R - 如何为 Keras 缩放/取消缩放
- r - 使用方括号表示法对数据帧行进行子集时,R 是否使用不精确匹配?
- python - 运行我的脚本时,屏幕底部出现 MySQL 和 Pyt 反复出现的问题
- linux - 递归查找与字符串匹配的所有目录,并在新目录中符号链接文件夹