문제

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.)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top