i am using basename() function in my code. Where i am including
#include <unistd.h>
and when i m compiling that code with -Wall flag it shows
following warning
warning: implicit declaration of function ‘basename’
if i am writing its declaration in my code
char * basename (const char *f开发者_StackOverflow中文版name);
then it does not show that warning
why this happening.?
You need to include <libgen.h>
.
The standard says it's in libgen.h
, kernel.org does so too.
If you look at the man
page for basename
:
man 3 basename
You'll see that you need to include libgen.h
to get the prototype for basename
(and similar function dirname
):
#include <libgen.h>
精彩评论