在Ubuntu 10.04编译时PATH_MAX没有宣布 [英] PATH_MAX not declared when compiling on Ubuntu 10.04

查看:159
本文介绍了在Ubuntu 10.04编译时PATH_MAX没有宣布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编译在Ubuntu 10.04 C程序为8.04制成。因为我们使用了 PATH_MAX ,并应在 limits.h中定义其他常量失败。根据各方面的资源,它应该是一个POSIX兼容的C库的一部分。

I am trying to compile a C program in Ubuntu 10.04 made for 8.04. It fails because we have used PATH_MAX and other constants that should be defined in limits.h. According to various resources, it should be part of a POSIX compatible C library.

这是一个错误在Ubuntu 10.04还是有解决这个的正确方法?

Is this a bug in Ubuntu 10.04 or is there a proper way of solving this?

推荐答案

POSIX定义了许多这样的限制是可选的。如果限制FOO没有在 limits.h中定义,这意味着该系统可能没有这样的限制或限制可能会在运行时或依赖于它应用到路径有所不同。在这些情况下,您可以使用的pathconf 执行fpathconf 的sysconf 功能和 _PC _ * _SC _ * 宏,如:

POSIX defines many such limits to be optional. If a limit FOO is not defined in limits.h, it means the system may have no such limit or the limit might vary at runtime or dependent upon the pathname it's applied to. In these cases, you use the pathconf, fpathconf, or sysconf functions and the _PC_* and _SC_* macros, as in:

path_max = pathconf("/", _PC_PATH_MAX);

page_size = sysconf(_SC_PAGE_SIZE);

不幸的是GNU(GNU C库)定义了许多限制为运行变量时,他们在Linux实际上恒定的,在一些(在我看来,非常误导)希望有一天的限制将被删除,应用程序将立即能够采取去除的限制的优点。然而,对于应用和内核鲁棒性,它实际上好得多具有固定限制,只要它们足够大(作为Linux限值)。

Unfortunately GNU (the GNU C library) defines many limits as runtime-variable when they're actually constant on Linux, in some (in my opinion, very misguided) hope that someday the limits will be removed and applications will immediately be able to take advantage of the removal of the limits. However, for application and kernel robustness, it's actually much better to have fixed limits as long as they're sufficiently large (as the Linux limits are).

这篇关于在Ubuntu 10.04编译时PATH_MAX没有宣布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆