I'm just starting to use cppcheck and am writing a configuration file to enable checking of various library functions. The ones for standard functions seem to work fine, but the ones for class member functions dont seem to work. Is there anything special I have to do for classes (do I need t?
Here's an example of a part that doesn't work (calls to TestFunct that do not use the return value or use a bool for the arg. are NOT detected).
<!-- int CAAA::TestFunct( int Inval ); --><functionname="CAAA::TestFunct"><use-retval/><returnValuetype="int"/><noreturn>false</noreturn><argnr="1"direction="in"><not-bool/></arg></function>
Whereas this works fine (calls to TestFunct2 that do not use the return value or use a bool for the arg. are ARE detected)
<!-- int TestFunct2( int Inval ); --><functionname="TestFunct2"><use-retval/><returnValuetype="int"/><noreturn>false</noreturn><argnr="1"direction="in"><not-bool/></arg></function>
Thanks in advance,
Colin
Last edit: COLIN VOSS 2020-01-29
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
One possible thing could be that a configuration is not used when the implementation is seen. Normally standard headers are not included and if there is a function like open that has implementation.. Cppcheck will assume that it is not the standard function but your own function.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
To give more information - both of those function checks are in the same cfg file (libCx) and loaded via --library=libCx so the cfg is being used, and the source code has calls to the two functions to be checked on consecutive lines..
....yet the standard function is being checked, the member function isn't.
...so nothing like any std function (I created CAAA::TestFunct so I could easily move it around to try and get a class member function check working. I've also tried it in a unique namespace too).
So there is nothing special about where the instance of the class lives (..if it is available via extern etc...)?
Last edit: COLIN VOSS 2020-01-30
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all,
I'm just starting to use cppcheck and am writing a configuration file to enable checking of various library functions. The ones for standard functions seem to work fine, but the ones for class member functions dont seem to work. Is there anything special I have to do for classes (do I need t?
Here's an example of a part that doesn't work (calls to TestFunct that do not use the return value or use a bool for the arg. are NOT detected).
Whereas this works fine (calls to TestFunct2 that do not use the return value or use a bool for the arg. are ARE detected)
Thanks in advance,
Colin
Last edit: COLIN VOSS 2020-01-29
Your configuration looks fine.
One possible thing could be that a configuration is not used when the implementation is seen. Normally standard headers are not included and if there is a function like
open
that has implementation.. Cppcheck will assume that it is not the standard function but your own function.Hi there & thanks for the reply.
To give more information - both of those function checks are in the same cfg file (libCx) and loaded via
--library=libCx
so the cfg is being used, and the source code has calls to the two functions to be checked on consecutive lines......yet the standard function is being checked, the member function isn't.
The original function being checked was...
<!-- ITC_Status_t CItcLib::ReadSSS_Data( SSS_ID_t SSS_ID, int *DataSize, void *pData ); -->
...so nothing like any std function (I created
CAAA::TestFunct
so I could easily move it around to try and get a class member function check working. I've also tried it in a unique namespace too).So there is nothing special about where the instance of the class lives (..if it is available via extern etc...)?
Last edit: COLIN VOSS 2020-01-30
Not sure what the problem is. I have tried your configuration and it seems to work;
foo.cpp
foo.cfg
Output: