This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

关于CCS做MISRA静态分析时候遇到的问题,请帮忙



公司安全产品要符合MISRA 2004规范,遇到的问题,代码段如下:

static uint8 firstSample = 0U;  /*此处报错 (MISRA-C:2004 8.7/R) Objects shall be defined at block scope if they are only accessed from within a single function                                                         (variable "firstSample")*/

uint8 handleDataSample(uint8 i)

{

    if(0U == i)

    {

           firstSample  = 1U;

    }

}

如果我再定义一个函数,然后firstSample 进行引用,则不会报error,   这是为什么?这里应该没有错误才对啊

用IAR工具做分析这里也没有报错。

所以这个是CCS误报的问题还是?