09-16-06 06:43 PM
Roman Mashak wrote:
> Hello,
>
> %cat foo.c
>
> #include <stdio.h>
> #include <sys/time.h>
>
> int main(void)
> {
> struct timeval tval;
>
> if (gettimeofday(&tval, NULL) == -1) {
> /* error handling */
> }
>
> return 0;
> }
>
> for this simple code 'splint foo.c' reports:
>
> Splint 3.0.1.7 --- 24 Jan 2003
>
> foo.c: (in function main)
> foo.c:8:6: Unrecognized identifier: gettimeofday
> Identifier used in code has not been declared. (Use -unrecog to inhibi
t
> warning)
>
> Finished checking --- 1 code warning
>
> Isn't it enought to include header declaring function?
Splint doesn't actually process standard header files introduced with
the #include directive by default. There are several reasons for this,
not the least of which is that many implementations use compiler
specific functionality in the header files that would cause splint to
choke. You can see this for yourself by using the -skip-iso-headers
command-line option on such a machine which will cause splint to try to
process the header files.
So how does splint know the prototypes of the standard functions?
Splint comes with several libraries that provide these prototypes (and
additional information) and uses them to check usage of standard
functions. By default splint loads only the prototypes for the C99
functions, gettimeofday is not a C99 function. The +unixlib
command-line option will tell splint to load the prototypes of the
functions defined by SUSv2, including gettimeofday.
Robert Gamble
[ Post a follow-up to this message ]
|