简体   繁体   English

使cppcheck跳过PACKAGE定义

[英]make cppcheck skip the PACKAGE definition

I'm using the GUI version of cppcheck 1.64 for static code analysis on C++-Builde-6 code. 我正在使用cppcheck 1.64的GUI版本对C ++-Builde-6代码进行静态代码分析。 For DLL exports and imports, the definition of PACKAGE is necessary: 对于DLL导出和导入,必须定义PACKAGE

/// 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: Cppcheck在遇到PACKAGE时停止,因为它不知道这意味着什么:

The code 'class PACKAGE TAppInfoDialog {' is not handled. 未处理代码“类PACKAGE TAppInfoDialog {”。 You can use -I or --include to add handling of this code. 您可以使用-I或--include添加对该代码的处理。

...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? 如果我可以使cppcheck 仅仅忽略PACKAGE “ keyword”,它会做正确的事情,但是怎么做呢? 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 ... 通过include路径包括它的原始定义似乎不是一个选择:cppcheck然后告诉了我很多关于 VCL框架标头的信息我无法更改 ...

The manual does not describe an option to do it, Google doesn't help, SO does not have an answer yet. 该手册没有描述执行此操作的选项,Google则没有帮助,因此尚无答案。

In the cppcheck issue tracker, I found the analogous problem #4707 (Microsoft 'abstract' and 'sealed' extension for class) – cppcheck . 在cppcheck问题跟踪器中,我发现了类似的问题#4707(类的Microsoft“抽象”和“密封”扩展名)– 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. 首席开发人员在这里建议创建一个文件,并将其包含在cppcheck运行中,但我使用的是GUI版本,没有选择包含单个文件的选项。 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 . 因此,我尝试在项目选项(XML文件)的include部分中添加一个Director,然后我编辑了对应于文件规范的行,但这显然是毫无意义的,因为此部分包含include path

What can I try next? 接下来我可以尝试什么?

A solution is to add the definition of PACKAGE (being empty) to the project file: 一种解决方案是将PACKAGE的定义(为空)添加到项目文件中:

<?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 我终于在主项目·danmar / cppcheck·GitHub上的项目仓库cppcheck / gui / projectfile.txt中找到了这个小而有价值的项目文件描述中的解决方案

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM