I wanted to find whether the cpp file has a certain function implemented.
For example if a() is present in the cpp file. How do I write a rule for this? I want it throw exception, if it is not present.
I wanted to find whether the cpp file has a certain function implemented.
For example if a() is present in the cpp file. How do I write a rule for this? I want it throw exception, if it is not present.
static code analysis tools are not used to find the compile or linking errors.
If the 'a` function or method is not declared and defined the compiler or linker will inform you - you will get an error.
If the CppCheck can't detect this kind of check, you can try CppDepend and its code query language CQLinq to create your custom rules.
from file in Files where file.ChildMethods.Where(m=>m.Name=="a").Count()==0 select file
I am a Cppcheck developer.
Cppcheck has "rules" and "addons". A "rule" is executed by "--rule". With a "rule" you cannot check this as far as I see.
With an "addon" you can definitely implement this. A good start is to loop through the scope list. If you see a function scope for "a()" you can see where the scope body is.
You can read more about addons in the cppcheck manual. http://cppcheck.sourceforge.net/manual.pdf
Chapter 12.