如何在Linux Ubuntu for C程序上使用splint?

时间:2015-07-27 04:20:45

标签: c linux ubuntu splint

我知道splint会发出有关C程序中问题的警告信息。

我使用'sudo apt-get install splint'将它安装在我的Ubuntu上。

如何在C程序或程序中使用它?

1 个答案:

答案 0 :(得分:1)

如果您在名为test.c的文件中创建以下C程序,则可以使用splint对源执行静态分析以查找可能的问题。

放入test.c文件的源代码:

#include <stdio.h>

int main(int argc, char *argv[])
{
    int a = 100; 
    int b[8];

    printf("Hello c\n");
    b[8] = 100; // error

    return 0;
}

用于针对C源文件运行splint以检查问题的命令行。

$ splint test.c +bounds -paramuse -varuse