|
From: Roman Mashak on 14 Sep 2006 22:10 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 inhibit warning) Finished checking --- 1 code warning Isn't it enought to include header declaring function? With best regards, Roman Mashak. E-mail: mrv(a)tusur.ru
From: Robert Gamble on 15 Sep 2006 00:33 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 inhibit > 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
From: Roman Mashak on 15 Sep 2006 03:10 Hello, Robert! You wrote on 14 Sep 2006 21:33:08 -0700: [skip] RG> specific functionality in the header files that would cause splint to RG> choke. You can see this for yourself by using the -skip-iso-headers RG> command-line option on such a machine which will cause splint to try to RG> process the header files. My splint (version 3.0.1.6) doesn't know this option. Perhaps it's too old. RG> So how does splint know the prototypes of the standard functions? RG> Splint comes with several libraries that provide these prototypes (and RG> additional information) and uses them to check usage of standard RG> functions. By default splint loads only the prototypes for the C99 RG> functions, gettimeofday is not a C99 function. The +unixlib RG> command-line option will tell splint to load the prototypes of the RG> functions defined by SUSv2, including gettimeofday. Thank you for thorough explanation. With best regards, Roman Mashak. E-mail: mrv(a)tusur.ru
|
Pages: 1 Prev: Solaris fork() to generate core file Next: option check and POSIX/SUS standards |