Question

I'm using the GUI version of cppcheck 1.64 for static code analysis on C++-Builde-6 code. For DLL exports and imports, the definition of PACKAGE is necessary:

/// A dialog exported from a BPL (a VCL-specific kind of DLL)
class PACKAGE MySharedDialog {

public:
    // lots of methods to-be checked

private:
    // lots of methods to-be checked

    // lots of members

};

Cppcheck stops when it encounters PACKAGE because it doesn't know what it means:

The code 'class PACKAGE TAppInfoDialog {' is not handled. You can use -I or --include to add handling of this code.

...and this of course means that the entire class isn't checked. If I could make cppcheck simply ignore the PACKAGE "keyword", it would do exactly the right thing, but how to do it? Including its original definition via include path, seems to be not an option: cppcheck then tells me a lot about headers of the VCL framework I cannot change...

The manual does not describe an option to do it, Google doesn't help, SO does not have an answer yet.

In the cppcheck issue tracker, I found the analogous problem #4707 (Microsoft 'abstract' and 'sealed' extension for class) – cppcheck. Here the lead developer suggests to create a file and (pre-?)include it to the cppcheck run, but I'm using the GUI version and there is no option to include a single file. So I tried to add a directors to the include section of my project options (an XML file), then I edited the corresponding line to a file specification, but that's clearly nonsense, because this section contains include paths.

What can I try next?

Was it helpful?

Solution

A solution is to add the definition of PACKAGE (being empty) to the project file:

<?xml version="1.0" encoding="UTF-8"?>
<project version="1">
    <defines>
        <define name="PACKAGE=" />
    </defines>    
</project>

This solution I finally found in this small but valuable project file description at the project repo cppcheck/gui/projectfile.txt at master · danmar/cppcheck · GitHub

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top