开发者

Implicit declaration of function basename in linux

开发者 https://www.devze.com 2023-03-28 12:52 出处:网络
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

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消