haziz haziz - 5 months ago 25
C Question

Where is PATH_MAX defined in Linux?

Which header file should I invoke with

to be able to use PATH_MAX as an int for sizing a string?

I want to be able to declare:

char *current_path[PATH_MAX];

But when I do so my compiler (Clang/LLVM on Linux) issues the following error:

recursive_find6.c:29:20: error: use of undeclared identifier 'PATH_MAX'
char *current_path[PATH_MAX];

I tried doing a google search but still no luck.

#include <limits.h>
Does NOT fix the problem/error.

Am I also correct that the value of PATH_MAX is an int?


Its in linux/limits.h.
#define PATH_MAX 4096 /* # chars in a path name including nul */

#include <linux/limits.h>

char current_path[PATH_MAX];

PATH_MAX has some flaws as mentioned in this blog (thanks paulsm4)