这个夹板警告的含义是什么?我可能做错了什么?
这是代码行:
bool cpfs_utimens(struct Cpfs *, char const *path, struct timespec const[2]);
运行 splint 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)
命名参数没有任何区别。
This is the line of code:
bool cpfs_utimens(struct Cpfs *, char const *path, struct timespec const[2]);
Running splint 3.1.2 generates this warning:
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)
Naming the parameter makes no difference.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这意味着当您声明参数 struct timespec const[2] 时,
[
和]
之间的2
不是必需的。将代码更改为:在 C/C++ 中,您不能要求特定大小的数组作为参数,因为数组被视为指针,而指针没有大小。
It means that when you declare the parameter
struct timespec const[2]
, the2
between the[
and]
is not required. Changing your code to:In C/C++, you cannot ask for an array of a certain size as a parameter, because the array is treated like a pointer and pointers don't have sizes.
在 C99 中(因为您使用
bool
),您可以通过像这样添加static
签名来要求参数数组的最小长度(如果在C) 仍然是指针参数,我想。
(而且我还不知道任何现有的编译器可以根据这些信息做一些有意义的事情。)
In C99 (since you use
bool
) you have the possibility to require a minimum length of a parameter array by addingstatic
like thisthe signature (if there is such a thing in C) is still that of a pointer parameter, thought.
(And also I don't know of any existing compiler that does something sensible from that information, yet.)