非标准函数返回类型

非标准函数返回类型

本文介绍了非标准函数返回类型:固定夹板解析错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是嵌入式系统XC8 C编译器(用于PIC微处理器)。以下是允许的:

 位富(){
    // ...
}

但作为非标C,夹板静态分析仪提供了以下错误:

And the file/line of the error is the function prototype in the respective .h file.

How can I fix this so Splint can analyse the rest of the file(s)? I think there might be two ways:

  1. I think I remember seeing a flag which can be passed to Splint via CLI which tells it to substitute a given non-standard type to a standard type (e.g. bit to unsigned char) but I can't seem to find it at all now!

  2. Also, perhaps there is an alternative way to write the c code that satisfies ANSI-C requirements while also still allowing XC8 to interpret the return type as bit?

Progress:

I found the following on a forum, but I can't find information on how to use the -D flag in the manual:

And

解决方案

If there's no option for the analysis program to do the substitution, you can of course do it using the preprocessor.

Have something like:

#if defined RUNNING_SPLINT
#define bit unsigned char
#endif

in e.g. a header that you make sure is included everywhere, enter code hereand make sure you define the pre-processor symbol RUNNING_SPLINT when Splint sees the code. It has a -D flag for this.

这篇关于非标准函数返回类型:固定夹板解析错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 18:53