3

Windows 上の PIC32 (XC32 v1.40 コンパイラ) で MPLAB X (3.26) を使用しています。レビューの一環として、誰かのコードの静的コード分析を行うためにスプリントを使用しようとしています。コンパイラの定義と検索パスのほとんどを並べ替えましたが、PIC32 std インクルード ファイルの解析エラーを回避するには少し困惑しています。

スプリントを実行するために使用しているコマンドは

splint ^
-D"__32MX370F512L__" ^
-D"__PIC32_FEATURE_SET__"=370 ^
-D"__LANGUAGE_C__" ^
+I"C:/Program Files (x86)/Microchip/xc32/v1.40/pic32mx/include/" ^
main.c

出力は次のようになります

< Location unknown >: Field name reused:
Code cannot be parsed.  For help on parse errors, see splint -help
parseerrors. (Use -syntax to inhibit warning)
< Location unknown >: Previous use of
< Location unknown >: Previous use of

.... approx 100 times then...

C:\Program Files (x86)\Microchip\xc32\v1.40\pic32mx\include\\stddef.h(4,18):
Datatype ptrdiff_t declared with inconsistent type: long int
A function, variable or constant is redefined with a different type. (Use
-incondefs to inhibit warning)
load file standard.lcd: Specification of ptrdiff_t: arbitrary integral type
C:\Program Files (x86)\Microchip\xc32\v1.40\pic32mx\include\\stddef.h(5,27):
Datatype size_t declared with inconsistent type: unsigned long int
load file standard.lcd: Specification of size_t:
arbitrary unsigned integral type
C:\Program Files (x86)\Microchip\xc32\v1.40\pic32mx\include\\stddef.h(6,13):
Datatype wchar_t declared with inconsistent type: int
load file standard.lcd: Specification of wchar_t: arbitrary integral type
C:\Program Files (x86)\Microchip\xc32\v1.40\pic32mx\include\\stdarg.h(75,36):
No type before declaration name (implicit int type): __builtin_va_list :
int
A variable declaration has no explicit type.  The type is implicitly int.
(Use -imptype to inhibit warning)
C:\Program Files (x86)\Microchip\xc32\v1.40\pic32mx\include\\stdarg.h(75,36):
Parse Error: Suspect missing struct or union keyword: __builtin_va_list :
int. (For help on parse errors, see splint -help parseerrors.)
*** Cannot continue.

最後の 1 つは、物事を停止させます。-skip-iso-headers のようなことを試しましたが、うまくいきませんでした。standard.lcd ファイルと xc32 std ファイルに問題があるようです。

誰か教えてくれませんか

  • < Location unknown >: Field name reused:手段またはおそらく言及しているものは何ですか?
  • std ヘッダー ファイルによる解析エラーを解決する方法はありますか?

これまでのところ、ヘッダー ファイルの問題を解決する唯一の方法は、型を定義することです。

-D"__builtin_va_list"=int ^
4

2 に答える 2

0

あなたのコード (または #include するコード) は、匿名のビットフィールドまたは構造体を使用していると思います。匿名構造体と匿名共用体は、C11 より前のバージョンの CのGNU 拡張によって提供されます。Splint は C11 について知らず (マニュアルで C99 についての言及しか見つけられず、Googleも 同意しています) 、GNU 拡張機能の部分的なサポート(gnu-extensions を検索) しか知らないため、それらを解析するのに苦労します。

XC8 の代わりに sdcc を使用していましたが、PIC18f46k22 用に作成されたコードで同様の問題が発生しました。

問題は pic18f46k22.h にあり、typedef ユニオン内に匿名の構造体 (具体的にはビットフィールド) が含まれていました。

このコード...

typedef union
  {
  struct
    {
    unsigned name0              : 1;
    unsigned name1              : 1;
    unsigned name2              : 1;
    unsigned name3              : 1;
    unsigned name4              : 1;
    unsigned                    : 1;
    unsigned                    : 1;
    unsigned                    : 1;
    };

  struct
    {
    unsigned name               : 6;
    unsigned                    : 2;
    };
  } __NAMEbits_t;

...これらのエラーが発生します...

< Location unknown >: Field name reused:
Code cannot be parsed.  For help on parse errors, see splint -help
parseerrors. (Use -syntax to inhibit warning)
< Location unknown >: Previous use of

...しかし、このコードはそうではありません。

  struct indv
    {
    unsigned name0              : 1;
    unsigned name1              : 1;
    unsigned name2              : 1;
    unsigned name3              : 1;
    unsigned name4              : 1;
    unsigned                    : 1;
    unsigned                    : 1;
    unsigned                    : 1;
    };
  struct all
    {
    unsigned name               : 6;
    unsigned                    : 2;
    };

  typedef union
    {
    struct indv individualbits;
    struct all  allbits;
    } __NAMEbits_t;
于 2016-10-24T16:54:07.877 に答える