4

对于一个项目,我们将一个项目从 Windows 切换到 Linux,而 PC-LINT 在 wine 上运行得很好,但我无法通过简单的测试程序运行 PC-LINT。PC-LINT 总是抱怨 STL 标头。我浏览了所有关于 gcc 的 Gimpel 文档,我使用 co-gcc.h 并生成了 lint_cppmac.hsize-options.lntgcc-include-path.lnt - 我们使用的是 PC-LINT 9.00k版,我试过了也有9.00k4。gcc 是 Ubuntu 14.04 LTS 中的 4.8.2 版本。

所以这就是我正在做的事情:

lint-nt.sh -voip +b std.lnt /home/test/test.cpp

lint-nt.sh 只是一个帮助脚本,用于在 Linux 下使用 wine 运行 PC-LINT 并用于输出转换(即反斜杠到斜杠......),包含以下内容:

#!/bin/bash
DIR=`dirname $0`
# Options that are passed to PC-Lint before any other options.
# -fff: Under Linux, filenames are case-sensitive.
# +rw(__is_pod): __is_pod is a GCC toolchain-specific keyword.
PREOPTS="-fff +rw(__is_pod)"
wine ${DIR}/LINT-NT.EXE $PREOPTS "$@" | tr '\\\r' '/ ' 

test.cpp 包含以下内容:

#include <iostream>

class Base {
public:
  Base(int i) : m_i(i), m_pi(new int[i]) { }
  ~Base() {}
  int get() { std::cout << m_i << std::endl; return m_i; }
private:
  int m_i;
  int *m_pi;
};

std.lnt 仅包含以下内容(文件是 gimpel 的默认文件)

co-gcc.lnt        // gcc compiler options
lib-stl.lnt       // STL

所以在运行时我得到这个错误(片段)

/home/test/test.cpp  11  Info 783: Line does not end with new-line 
                         _ 
  Base(int i) : m_i(i), m_pi(new int[i]) { } 
/home/test/test.cpp  5  Info 1732: new in constructor for class 'Base' which 
    has no assignment operator 
/home/test/test.cpp  5  Info 1733: new in constructor for class 'Base' which 
    has no copy constructor 
/home/test/test.cpp  5  Info 737: Loss of sign in promotion from int to 
    unsigned int 
           _ 
  ~Base() {} 
/home/test/test.cpp  6  Warning 1540: Pointer member 'Base::m_pi' (line 10) 
    neither freed nor zeroed by destructor 
/home/test/test.cpp  10  Info 830: Location cited in prior message 
                        _ 
  int get() { std::cout << m_i << std::endl; return m_i; } 
/home/test/test.cpp  7  Error 40: Undeclared identifier 'cout' 
/home/test/test.cpp  7  Info 701: Shift left of signed quantity (int) 
/home/test/test.cpp  7  Error 40: Undeclared identifier 'endl' 
/home/test/test.cpp  7  Warning 504: Unusual shift operation (left side unparenthesized) 
/home/test/test.cpp  7  Info 701: Shift left of signed quantity (int) 
/home/test/test.cpp  7  Warning 522: Highest operation, operator '<<', lacks side-effects 
/home/test/test.cpp  7  Info 1762: Member function 'Base::get(void)' could be made const 
_ 
}; 
/home/test/test.cpp  11  Info 1712: default constructor not defined for class 
    'Base' 

--- Wrap-up for Module: /home/tall/test.cpp 

Info 753: local class 'Base' (line 3, file /home/tall/test.cpp) not referenced 
 /home/test/test.cpp  3  Info 830: Location cited in prior message 
Info 766: Header file '/usr/include/c++/4.8/iostream' not used in module '/home/test/test.cpp' 

我尝试使用命名空间 std 和不使用。我尝试了测试文件,<string>它变得更糟。

我很感激每一个提示让这个工作。先感谢您

4

0 回答 0