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?
Negative. It works properly to me. Are you sure you included the correct header?
#include <string.h>
#include <libgen.h>
static void foo(char *path) {
char *bname;
char *path2 = strdup(path);
bname = basename(path2);
}
Could you tell us more about your compiling environment?
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