Questions about using CPPCheck with Codelite 6

General questions regarding the usage of CodeLite
ColinTaylor
CodeLite Expert
Posts: 152
Joined: Fri Jul 15, 2011 2:49 pm
Genuine User: Yes
IDE Question: C++
Contact:

Questions about using CPPCheck with Codelite 6

Post by ColinTaylor »

Windows 8.1 / MinGW 4.7.1 / wxWidgets 3.0.0 / Codelite 6

I've just tried running CPPCheck on a minimal app, which was created using Create New Project -> "Executable (wxWidgets + wxFBFrame)"

[1] Running CPPCheck on Minimal gave the following results
Starting cppcheck: "E:\Dev\CodeLite\codelite_cppcheck.exe" --enable=style --enable=performance --enable=portability --enable=unusedFunction --enable=missingInclude --enable=information --std=posix --std=c99 --std=c++11 --force --template gcc --file-list="F:\CodeliteWorkspaces\Play\.codelite\cppcheck.list"
Checking F:\CodeliteWorkspaces\Play\Minimal\gui.cpp...

Checking F:\CodeliteWorkspaces\Play\Minimal\main.cpp...
F:\CodeliteWorkspaces\Play\Minimal\main.cpp:23: style: The function 'OnInit' is never used.
:: information: Cppcheck cannot find all the include files (use --check-config for details)
Checking usage of global functions..
===== cppcheck analysis ended. Found 0 possible errors=====
[2] Next thing was to run cppcheck from commandline with the --check config option
"E:\Dev\CodeLite\codelite_cppcheck.exe" --check-config --file-list="F:\CodeliteWorkspaces\Play\.codelite\cppcheck.list"
which gave the following results
Checking F:\CodeliteWorkspaces\Play\Minimal\gui.cpp...
[F:\CodeliteWorkspaces\Play\Minimal\gui.h:11]: (information) Include file: <wx/artprov.h> not found.
[F:\CodeliteWorkspaces\Play\Minimal\gui.h:12]: (information) Include file: <wx/xrc/xmlres.h> not found.
[F:\CodeliteWorkspaces\Play\Minimal\gui.h:13]: (information) Include file: <wx/intl.h> not found.
[F:\CodeliteWorkspaces\Play\Minimal\gui.h:14]: (information) Include file: <wx/string.h> not found.
[F:\CodeliteWorkspaces\Play\Minimal\gui.h:15]: (information) Include file: <wx/bitmap.h> not found.
[F:\CodeliteWorkspaces\Play\Minimal\gui.h:16]: (information) Include file: <wx/image.h> not found.
[F:\CodeliteWorkspaces\Play\Minimal\gui.h:17]: (information) Include file: <wx/icon.h> not found.
[F:\CodeliteWorkspaces\Play\Minimal\gui.h:18]: (information) Include file: <wx/menu.h> not found.
[F:\CodeliteWorkspaces\Play\Minimal\gui.h:19]: (information) Include file: <wx/gdicmn.h> not found.
[F:\CodeliteWorkspaces\Play\Minimal\gui.h:20]: (information) Include file: <wx/font.h> not found.
[F:\CodeliteWorkspaces\Play\Minimal\gui.h:21]: (information) Include file: <wx/colour.h> not found.
[F:\CodeliteWorkspaces\Play\Minimal\gui.h:22]: (information) Include file: <wx/settings.h> not found.
[F:\CodeliteWorkspaces\Play\Minimal\gui.h:23]: (information) Include file: <wx/sizer.h> not found.
[F:\CodeliteWorkspaces\Play\Minimal\gui.h:24]: (information) Include file: <wx/statusbr.h> not found.
[F:\CodeliteWorkspaces\Play\Minimal\gui.h:25]: (information) Include file: <wx/frame.h> not found.
1/2 files checked 54% done
Checking F:\CodeliteWorkspaces\Play\Minimal\main.cpp...
[F:\CodeliteWorkspaces\Play\Minimal\main.h:18]: (information) Include file: <wx/wx.h> not found.
2/2 files checked 100% done
Are these results what I should expect, or are there any settings/actions I can do so that CPPCheck can find the wx include files?

Thanks for any help/information, Colin
User avatar
eranif
CodeLite Plugin
Posts: 6373
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Questions about using CPPCheck with Codelite 6

Post by eranif »

IIRC, David did a fix that should fix this ( need to check git log for this ;) ) in git head

Eran
Make sure you have read the HOW TO POST thread
ColinTaylor
CodeLite Expert
Posts: 152
Joined: Fri Jul 15, 2011 2:49 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Questions about using CPPCheck with Codelite 6

Post by ColinTaylor »

Many thanks for the response; I don't take codelite from git so I might have a long wait before getting this fix!
User avatar
eranif
CodeLite Plugin
Posts: 6373
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Questions about using CPPCheck with Codelite 6

Post by eranif »

The next release will definitely be faster. The previous one took 6 month - this won't be the case this time
Eran
Make sure you have read the HOW TO POST thread
ColinTaylor
CodeLite Expert
Posts: 152
Joined: Fri Jul 15, 2011 2:49 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Questions about using CPPCheck with Codelite 6

Post by ColinTaylor »

That's good to know, thanks :-)

In the meantime I've just downloaded "codelite-6.1-git-master-mingw4.8.1.exe" that you recently posted in another thread.
There definitely have been changes to the cppcheck settings dialog, but I haven't yet managed to successfully get cppcheck to find all include files, still trying!
User avatar
Jarod42
CodeLite Expert
Posts: 239
Joined: Wed Sep 30, 2009 5:54 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Re: Questions about using CPPCheck with Codelite 6

Post by Jarod42 »

In the command line, you may use the

Code: Select all

-I directory
switch (same as the one for gcc) to add include directory.
This option cannot be passed from Codelite 6.0
(I don't know the status from trunk).

You may uncheck

Code: Select all

--enable=missingInclude
to remove the relative information log.
User avatar
eranif
CodeLite Plugin
Posts: 6373
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Questions about using CPPCheck with Codelite 6

Post by eranif »

This is good know, note that cppcheck is next on my todo list, mainly:
cppcheck will be using all the defintions + include paths from the project build settings, to avoid manually re-typing all of them for cppcheck

Eran
Make sure you have read the HOW TO POST thread
ColinTaylor
CodeLite Expert
Posts: 152
Joined: Fri Jul 15, 2011 2:49 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Questions about using CPPCheck with Codelite 6

Post by ColinTaylor »

Thanks for the information and updates.

The updated Codelite (6.1) is certainly a big improvement but there is still one thing about CPPcheck that I can't get working

It regularly reports that a function is never used when that's not strictly true (IMHO!). There's too much code to upload it all so I'll try and explain it via fragments.
I derive a class from wxPrintout, and override a few virtual methods, GetPage info being an example ...

Code: Select all

class CPrintout: public wxPrintout
{
public:
   CPrintout (wxStyledTextCtrl* StyledTextCtrl, const wxString &title = wxT ("TextEdit"));
   ~CPrintout ();
   virtual void GetPageInfo (int *minPage, int *maxPage, int *selPageFrom, int *selPageTo);
...
and there's the implementation of GetPageInfo too of course ...

Code: Select all

void CPrintout::GetPageInfo (int *minPage, int *maxPage, int *selPageFrom, int *selPageTo)
{
   // initialize values
   *minPage = 0;
   *maxPage = 0;
   *selPageFrom = 0;
   *selPageTo = 0;

   // scale DC if possible
...
Running cppcheck on this reports
F:\CodeliteWorkspaces\ActiveProjects\TextEdit\TextEditMain.cpp:2593: style: The function 'GetPageInfo' is never used.
which is sort of true, but that function is definitely called, even though its not called explictly by my app!

The difficulty comes from the fact that cppcheck reports a long list of "function xxx is never used" and its tricky to find the functions that are really redundant, compared to the 'false positives' ones like I reported above.

Does anyone know if cppcheck can be configured to understand inherited functions that are called by the wx framework?

Thanks!
User avatar
Jarod42
CodeLite Expert
Posts: 239
Joined: Wed Sep 30, 2009 5:54 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Re: Questions about using CPPCheck with Codelite 6

Post by Jarod42 »

That problem should be reported to cppcheck team, not here.
ColinTaylor
CodeLite Expert
Posts: 152
Joined: Fri Jul 15, 2011 2:49 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Questions about using CPPCheck with Codelite 6

Post by ColinTaylor »

Thanks a lot for the tip. Looking for the cppcheck forum was useful, as I found a standalone version of the cppcheck program and this doesn't produce the 'false' warnings I see when running it from within codelite. ;)
Post Reply