basename() returning int?

Posted by EB on Stack Overflow See other posts from Stack Overflow or by EB
Published on 2010-05-08T07:34:57Z Indexed on 2010/05/08 7:38 UTC
Read the original article Hit count: 175

Filed under:

Probably something stupid I'm missing but, why am I getting this warning?

static void foo(char *path) {
    char *bname;
    char *path2 = strdup(path);
    bname = basename(path2);

(line with basename() call): warning: assignment makes pointer from integer without a cast

Indeed, if I change to this, the warning goes away:

    bname = (char *)basename(path2);

man 3 basename tells me:

char *basename(char *path);

Both dirname() and basename() return pointers to null-terminated strings.

What gives?

© Stack Overflow or respective owner

Related posts about c