题
这是代码的行:
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中有这样的东西)仍然是指针参数,认为。
(而且我也不知道有任何现有的编译器可以从这些信息中做明智的事情。)
不隶属于 StackOverflow