Linux 中 PATH_MAX 在哪里定义? [英] Where is PATH_MAX defined in Linux?
本文介绍了Linux 中 PATH_MAX 在哪里定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我应该使用 #include
调用哪个头文件才能使用 PATH_MAX 作为 int 来调整字符串大小?
Which header file should I invoke with #include
to be able to use PATH_MAX as an int for sizing a string?
我希望能够声明:
char *current_path[PATH_MAX];
但是当我这样做时,我的编译器(Linux 上的 Clang/LLVM)会出现以下错误:
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
不能解决问题/错误.
#include <limits.h>
Does NOT fix the problem/error.
PATH_MAX 的值是一个整数,我也正确吗?
Am I also correct that the value of PATH_MAX is an int?
推荐答案
在linux/limits.h
中.#define PATH_MAX 4096/* # 路径名中的字符包括空 */
#include <linux/limits.h>
char current_path[PATH_MAX];
PATH_MAX
有一些缺陷,如 这个博客(感谢paulsm4)
PATH_MAX
has some flaws as mentioned in this blog (thanks paulsm4)
这篇关于Linux 中 PATH_MAX 在哪里定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文