如果你
#include <libgen.h>
对于dirname@H_301_7@您已经获得了POSIX,而不是GNU版本的basename(). (即使你
#define _GNU_SOURCE
据我所知,在C中没有条件导入.是否有gcc特定技巧?
char *gnu_basename(char *path) { char *base = strrchr(path,'/'); return base ? base+1 : path; }
这样,您的程序也将更加便携.