make cppcheck跳过PACKAGE定义 [英] make cppcheck skip the PACKAGE definition

查看:524
本文介绍了make cppcheck跳过PACKAGE定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用cppcheck 1.64的GUI版本用于C ++ - Builde-6代码的静态代码分析。对于DLL导入和导入, PACKAGE 的定义是必要的:

  ///从BPL(一种特定于VCL的DLL)导出的对话框
class PACKAGE MySharedDialog {

public:
//许多要检查的方法

private:
//许多要检查的方法

//很多成员

};

Cppcheck遇到 PACKAGE 不知道它是什么意思:


不处理代码'PACKAGE TAppInfoDialog {'。您可以使用-I或--include添加此代码的处理。


...这当然意味着整个类未检查。如果我可以使cppcheck 简单地忽略 PACKAGE 关键字,它会做正确的事情去做吧?通过include路径包含其原始定义似乎不是一个选项:cppcheck然后告诉我 VCL框架的头部 我不能改变 ...



手册没有描述选项



在cppcheck问题跟踪器中,我发现类似的问题#4707(类的微软抽象和密封扩展) - cppcheck 。这里领导开发人员建议创建一个文件,(pre - ?)包括它到cppcheck运行,但我使用的是GUI版本,没有选项包括单个文件。所以我试图添加一个董事到我的项目选项(一个XML文件)的包含部分,然后我编辑相应的行文件规范,但这显然是废话,因为这一部分包含包含路径



我可以尝试什么?

解决方案

PACKAGE (为空)的定义添加到项目文件中:

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

这个解决方案我终于找到了这个小而有价值的项目文件描述在项目repo cppcheck / gui / projectfile.txt在master·danmar / cppcheck·GitHub


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?

解决方案

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

这篇关于make cppcheck跳过PACKAGE定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆