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 *fname);
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With