Author Topic: cppcheck not working  (Read 14283 times)

Offline danilo2

  • Single posting newcomer
  • *
  • Posts: 5
cppcheck not working
« on: November 15, 2012, 12:52:58 pm »
Hi!
I'm using Fedora 17 and I've installed codeblocks with plugins from my repo (it is 10.05 version).
When I'm trying to run cppcheck plugin I get error in console:
Code
cppcheck --version
Cppcheck 1.57
cppcheck --verbose --all --style --xml --file-list=CppCheckInput.txt
cppcheck: error: unrecognized command line option: "--all".
Failed to parse cppcheck XML file.
Probably it's not produced correctly.

Is it a bug?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: cppcheck not working
« Reply #1 on: November 15, 2012, 01:03:23 pm »
Is it a bug?
No. Your CppCheck is too new or your C::B too old. So either you use an older CppCheck or a nightly of C::B.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline danilo2

  • Single posting newcomer
  • *
  • Posts: 5
Re: cppcheck not working
« Reply #2 on: November 16, 2012, 12:42:36 pm »
Thank you, I've installed the newest version from trunk and these errors are gone, but there is other poblem.

When I input a sample (wrong code like this):
Code
#include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!"s22 << endl
    dsad()
    return 0;
}

and click plugins->cppcheck i get the output:
Code
cppcheck --version
Cppcheck 1.57
Switching working directory to : /home/[username]/dev/test/
cppcheck --verbose --enable=all --enable=style --xml --file-list=CppCheckInput.txt
Checking main.cpp...
Checking usage of global functions..
<?xml version="1.0" encoding="UTF-8"?>
<results>
</results>

And nothing happens - no lines are underscored I see no notifications etc - how can I make this plugin running? :(

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: cppcheck not working
« Reply #3 on: November 16, 2012, 01:36:18 pm »
Why do you think you'll get a notification for this code?
Check the documentation of CppCheck for the list supported errors detected by it.

Probably you can try "int *a=new int;" and don't put the delete there or "int *a=new int; delete [] a;"
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline danilo2

  • Single posting newcomer
  • *
  • Posts: 5
Re: cppcheck not working
« Reply #4 on: November 16, 2012, 02:17:11 pm »
Thank you,
I was thinking that cppcheck will check for any syntax error too. Is it possible to get notifications about such errors like no semicolon on end of the line or undeclared property usage?

Offline danilo2

  • Single posting newcomer
  • *
  • Posts: 5
Re: cppcheck not working
« Reply #5 on: November 16, 2012, 02:19:31 pm »
Additionl, cppcheck for following code does not return any errors also:

Code
#include <iostream>

using namespace std;

int main()
{
    cout << "Hello world!" << endl
    int* x = new int;
    return 0;
}

 ::)

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: cppcheck not working
« Reply #6 on: November 16, 2012, 02:34:40 pm »
I was thinking that cppcheck will check for any syntax error too. Is it possible to get notifications about such errors like no semicolon on end of the line or undeclared property usage?
Yes, press f9 constantly :)

For the other error, test with cppcheck run on the command line.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline danilo2

  • Single posting newcomer
  • *
  • Posts: 5
Re: cppcheck not working
« Reply #7 on: November 16, 2012, 02:48:06 pm »
from the command line the cppcheck prints worning about memory leak - this is cool.

Do I really need to constantly recompile project to get know about errors? What if it is custom makefile project or its compilation take more than a few second?

Eclipse (which is horrbily slow) can check for errors while typing :(

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: cppcheck not working
« Reply #8 on: November 16, 2012, 03:01:34 pm »
You only need to (re-)build if you want to check for errors the compiler can find, but cppcheck not.
And it warns about memleak from inside C::B too, at least here, if you add the missing semicolon.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: cppcheck not working
« Reply #9 on: November 16, 2012, 03:07:52 pm »
Eclipse (which is horrbily slow) can check for errors while typing :(
It also runs the compiler, but does it behind your back. With C::B you have control. Probably in a future release we will add this feature, but currently it isn't available.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]