What is the meaning of this splint warning and what might I be doing wrong?
문제
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.
해결책
It means that when you declare the parameter struct timespec const[2]
, the 2
between the [
and ]
is not required. Changing your code to:
bool cpfs_utimens(struct Cpfs *, char const *path, struct timespec const[]);
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.
다른 팁
In C99 (since you use bool
) you have the possibility to require a minimum length of a parameter array by adding static
like this
bool cpfs_utimens(struct Cpfs *, char const *path, struct timespec const[static 2]);
the 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.)
제휴하지 않습니다 StackOverflow