I'm using dirname from libgen.h to get the directory path from a filename's path.
This is it's signature:
char * dirname (char *path)
When compiling on a 32 bit machine or using -m32 with gcc, it all works fine.
My code looks like this:
char* path = "/path/to/my/file.txt";
char* path_cpy = strdup(path);
const char* dir = (const char*)dirname(path_cpy);
If I compile on a 64 bit machine, I get the warning:
"warning: cast to pointer from integer of different size"
This will fix the warning, but crashes at runtime:
const char* dir = (const char*)(uintptr_t)dirname(path_cpy);
I have never tried to cross compile for 32/64 bit before, is there a way to fix this?