K
KM
Questions about a compiler warning when using the 'basename'
library function...
This is my test program 'foo.c'.
#include <stdio.h>
#include <string.h>
int main (int argc, char **argv)
{
char *bname = (char *) basename("/a/b/cdef");
printf("bname is %s.\n", bname);
return 0;
}
Compiling produces a warning.
$ gcc -Wall -c -o foo.o foo.c
foo.c: In function ‘main’:
foo.c:6: warning: implicit declaration of function ‘basename’
The #includes don't pull in a declaration of basename.
$ gcc -E foo.c | grep basename
char *bname = (char *) basename("/a/b/cdef");
The program links and runs, printing "bname is cdef."
What's going on with 'basename'?
Can I and should I modify the program to remove the compiler warning?
Thanks
library function...
This is my test program 'foo.c'.
#include <stdio.h>
#include <string.h>
int main (int argc, char **argv)
{
char *bname = (char *) basename("/a/b/cdef");
printf("bname is %s.\n", bname);
return 0;
}
Compiling produces a warning.
$ gcc -Wall -c -o foo.o foo.c
foo.c: In function ‘main’:
foo.c:6: warning: implicit declaration of function ‘basename’
The #includes don't pull in a declaration of basename.
$ gcc -E foo.c | grep basename
char *bname = (char *) basename("/a/b/cdef");
The program links and runs, printing "bname is cdef."
What's going on with 'basename'?
Can I and should I modify the program to remove the compiler warning?
Thanks