このスプリント警告の意味は何ですか、そして私は何を間違えているのでしょうか?

StackOverflow https://stackoverflow.com/questions/3655566

  •  01-10-2019
  •  | 
  •  

質問

これはコードの行です:

bool cpfs_utimens(struct Cpfs *, char const *path, struct timespec const[2]);

スプリント3.1.2を実行すると、この警告が生成されます。

cpfs.h:21:74: Function parameter times declared as manifest array (size
                 constant is meaningless)
  A formal parameter is declared as an array with size.  The size of the array
  is ignored in this context, since the array formal parameter is treated as a
  pointer. (Use -fixedformalarray to inhibit warning)

パラメーターに名前を付けると違いはありません。

役に立ちましたか?

解決

それは、パラメーターを宣言するときにそれを意味します struct timespec const[2], 、 2 間に [] 必須ではありません。コードの変更:

bool cpfs_utimens(struct Cpfs *, char const *path, struct timespec const[]);

C/C ++では、アレイはポインターのように扱われ、ポインターがサイズがないため、特定のサイズの配列をパラメーターとして要求することはできません。

他のヒント

C99で(使用しているため bool)追加することにより、パラメーター配列の最小長さを必要とする可能性があります static このような

bool cpfs_utimens(struct Cpfs *, char const *path, struct timespec const[static 2]);

署名(cにそのようなものがある場合)は、ポインターパラメーターの署名です。

また、その情報から賢明なことをしている既存のコンパイラをまだ知りません。)

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top