Within our C++ project we are getting an issue flagged up within a .hpp file. Specifically it is ‘“using” directives should not be used in header files’ * cpp:S1003. I would not expect this to be being flagged at present as the code is as follows:
template <class Proto>
void setTimeFrom(const Application::data_shot_t& shot, Proto& msg) {
using namespace std;
using namespace std::chrono;
...
}
Both the using namespace lines are being flagged but both are within a function scope. The rule its self includes in its description
- MISRA C++:2008, 7-3-6 - using-directives and using-declarations (excluding class scope or function scope using-declarations) shall not be used in header files.
My only thought at present is the rule as implemented forbids all use of using in a header file but the MISRA statement only requires items outside of a function scope. On that basis, I am starting this off as a bug as the rule does not match the MISRA statement. That might all be beside the point if * ISO/IEC 14882:2003, sections 7.3.3, 7.3.4 then requires they all be excluded.
I am using SonarQube scanner to analyses a C++ and C project. We use the build wrapper around the GNU compile chain within GNU make. Server reports the version as * Version 7.0 (build 36138)
#bug:fp