Consider the following Code snippet:
#include <iostream>
using namespace std;
class MyClass : public std::basic_streambuf<char>
{
public :
int_type overflow(int_type c = traits_type::eof());
};</char></iostream>
CppCheck Does not detects that the function 'overflow' is virtual in the std::basic_streambuf class and
does not hits the predefined rule which is
"The function '$symbol' overrides a function in a base class but is not marked with a 'override' specifier."
It Happens because the class that is inherited is in a lib function and the Code File does not exits in the folder path specified.
Can any one tell me what should I do to hit the Rule.
Any help would be appreciated..
Note : The Corresponding Function is in the checkclass.cpp - void CheckClass::checkOverride()
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can insert / write code inside blocks sourrounded by ~~~ (each on its own line) to avoid that the code is changed / characters are inserted.
Example:
~~~
// write your code here
~~~
Currently we do not have information in the Cppcheck library configuration whether a function is virtual. Not sure if that would really help or if it is some other bug.
A ticket requesting to make it possible that functions can be marked virtual in the library configuration already exists: https://trac.cppcheck.net/ticket/8468
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Consider the following Code snippet:
#include <iostream>
using namespace std;
class MyClass : public std::basic_streambuf<char>
{
public :
int_type overflow(int_type c = traits_type::eof());
};</char></iostream>
CppCheck Does not detects that the function 'overflow' is virtual in the std::basic_streambuf class and
does not hits the predefined rule which is
"The function '$symbol' overrides a function in a base class but is not marked with a 'override' specifier."
It Happens because the class that is inherited is in a lib function and the Code File does not exits in the folder path specified.
Can any one tell me what should I do to hit the Rule.
Any help would be appreciated..
Note : The Corresponding Function is in the checkclass.cpp - void CheckClass::checkOverride()
There is unwanted characters in the above code
Here is the updated code :
include <iostream></iostream>
using namespace std;
class MyClass : public std::basic_streambuf<char>
{
public :
int_type overflow(int_type c = traits_type::eof());
};</char>
Last edit: Sourabh Joshi 2019-03-12
You can insert / write code inside blocks sourrounded by
~~~
(each on its own line) to avoid that the code is changed / characters are inserted.Example:
Currently we do not have information in the Cppcheck library configuration whether a function is
virtual
. Not sure if that would really help or if it is some other bug.A ticket requesting to make it possible that functions can be marked
virtual
in the library configuration already exists:https://trac.cppcheck.net/ticket/8468