【问题标题】:How to resolve a Splint Parse Error for `int32 l[2]`如何解决“int32 l[2]”的夹板解析错误
【发布时间】:2020-03-31 18:59:25
【问题描述】:

我有一些 C 代码,其中包含一个专有遗留应用程序的标头。我无法修改标题。我收到以下代码的夹板解析错误:

#if defined(HAS_LONGLONG)
    /* removed for brevity */
#elif defined(HAS_INT64)
    /* removed for brevity */
#else
  typedef union {
    int32   l[2]; /* This is the line that is causing the parse error in splint */
    double  d;
  } int64;
#endif

我可以将任何参数传递给夹板以使其正常工作吗?

平台是 64 位,但旧版应用程序是 32 位。

我正在运行夹板:

[me@host]$ splint -I/path/to/include -preprox -warnposix

Splint 3.1.1 --- 28 Apr 2003
/path/to/include/some_header.h:7:10:
    Parse Error. (For help on parse errors, see splint -help parseerrors.)
*** Cannot continue.

如果没有 -preprox 和 -warnposix,我会在旧版标头中遇到很多其他错误。

【问题讨论】:

  • 你介意显示int32吗?
  • @JL2210 是typedef int int32;
  • 如果你通过-Dint32=int会发生什么?
  • @JL2210 成功了,谢谢。您介意发布一个带有解释的答案,我会奖励给您吗?
  • 那里。我还提供了常见问题解答的链接以供将来参考。

标签: c splint


【解决方案1】:

你应该通过-Dint32=int

splint FAQ 声明如下:

  1. 我使用非标准关键字和数据类型的编译器在嵌入式系统上开发代码。我想在我的代码上运行 Splint,但这些非标准关键字会导致解析错误。我该怎么办?

    你可以经常使用-D来解决这个问题。

    如果只想忽略某个关键字,可以添加-Dnonstandardkeyword=,让预处理器消除该关键字,其中nonstandardkeyword是关键字的名称。同样,您可以使用-Dspecialtype=int 将自定义类型解析为 int。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-06-23
    • 1970-01-01
    • 2014-01-09
    • 2016-02-28
    • 1970-01-01
    • 2017-10-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多