Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在limits.h, 和 POSIX 联机帮助页的各个地方,都有对PATH_MAX和的引用NAME_MAX。这些如何相互关联?他们的官方文档在哪里?如何在运行时获取它们,以及(如果相关)C、Python 和 GNU (shell) 环境的编译时间?
limits.h
PATH_MAX
NAME_MAX
PATH_MAX是文件系统路径的最大长度。 NAME_MAX是文件名的最大长度(在特定位置)。因此,/foo/bar受 限制PATH_MAX,并且只有bar部分的长度受 限制NAME_MAX。
/foo/bar
bar
您可以在运行时通过pathconf、 as_PC_PATH_MAX和获得这些_PC_NAME_MAX,尽管标准做法通常只是在编译时使用静态宏。我认为使用运行时选项会更好,因为您可以通过这种方式潜在地支持更长的值,但我不确定哪些(如果有)系统实际上提供了pathconf大于值的值的返回POSIX_FOO_MAX值。
pathconf
_PC_PATH_MAX
_PC_NAME_MAX
POSIX_FOO_MAX