2

这是代码行:

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)

命名参数没有区别。

4

2 回答 2

5

这意味着当你声明参数时struct timespec const[2],和之间2的不是必需的。将您的代码更改为:[]

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

在 C/C++ 中,您不能要求一定大小的数组作为参数,因为数组被视为指针,而指针没有大小。

于 2010-09-07T03:34:18.860 回答
2

在 C99 中(因为您使用),您可以通过像这样bool添加来要求参数数组的最小长度static

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

签名(如果 C 中有这样的东西)仍然是指针参数的签名,我想。

(而且我还不知道任何现有的编译器可以从这些信息中做出明智的事情。)

于 2010-09-07T12:30:28.957 回答