Yes, use all --library options that apply. The --library=posix can't be loaded by default because there are many users that don't target posix systems.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I can find cppcheck throwing Resource Leak whenever there is a fopen() call is made but fclose is missing.
#include <stdio.h>
include <stdlib.h>
int main()
{
FILE * fp;
fp = fopen ("file.txt", "w+");
fprintf(fp, "%s %s %s %d", "We", "are", "in", 2016);
return(0);
}
Results: (error) Resource leak: fp
fclose(fp) is missing.
but
define FNAME "a.txt"
int main()
{
int fd;
fd=open(FNAME,O_RDONLY,0);
return 0;
}
Cppcheck wont throw any error as resource leak.
please reply if any one is aware of this.
Thanks,
Pavithra
By default, cppcheck does not catch
open()
leaks for some reason, but it will if invoked with--library=posix
switch.Yes, use all
--library
options that apply. The--library=posix
can't be loaded by default because there are many users that don't target posix systems.