非标准函数返回类型:固定夹板解析错误 [英] Non-standard function return types: Fixing Splint parse error

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

问题描述

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

 位富(){
    // ...
}

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


  

解析错误:非函数声明:位:
  --------------------------------------
                 INT。


和错误的文件/行是函数原型在各自的.h文件中。

我怎样才能解决这个如此夹板可以分析文件(S)的休息吗?我觉得可能有两种方式:


  1. 我想我记得看到它可以传递通过CLI告诉它来代替一个给定的非标型为标准型,以夹板标志(如位无符号字符),但我似乎无法给发现它在所有吧!


  2. 此外,也许有写C code,它满足ANSI-C要求,同时仍然允许XC8国米preT的返回类型为的另一种方式位


进展:

我发现在一个论坛以下,,但我无法找到如何在的手动


  

要忽略一个关键词,增加-Dnonstandardkeyword =使
  preprocessor消除



  

使用-Dspecialtype = INT做出一个自定义类型解析为int。



解决方案

如果没有选项的分析程序做替换,你当然可以不使用preprocessor它。

有类似:

 #如果定义RUNNING_SPLINT
#定义位无符号字符
#万一

在如您确保到处包含的头,在这里输入code ,并确保您定义的pre-处理器符号 RUNNING_SPLINT 当夹板看到code。它有一个 -D 标志这一点。

I'm using the embedded-system XC8 C compiler (for PIC microprocessors). The following is allowed:

bit foo(){
    //...
}

but being non-standard C, the Splint static analyser gives the following error:

Parse Error: Non-function declaration: bit : "--------------------------------------" int.

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:

To ignore a keyword, add -Dnonstandardkeyword= to make the preprocessor eliminate it

And

use -Dspecialtype=int to make a custom type parse as an int.

解决方案

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.

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

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