News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

cppcheck not working

Started by danilo2, November 15, 2012, 12:52:58 PM

Previous topic - Next topic

danilo2

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:
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?

MortenMacFly

Quote from: danilo2 on November 15, 2012, 12:52:58 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

danilo2

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):
#include <iostream>

using namespace std;

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


and click plugins->cppcheck i get the output:
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? :(

oBFusCATed

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!]

danilo2

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?

danilo2

Additionl, cppcheck for following code does not return any errors also:

#include <iostream>

using namespace std;

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


::)

oBFusCATed

Quote from: danilo2 on November 16, 2012, 02:17:11 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!]

danilo2

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 :(

Jenna

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.

oBFusCATed

Quote from: danilo2 on November 16, 2012, 02:48:06 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!]