PATH_MAX is not declared when compiling on Ubuntu 10.04

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

Is this a bug in Ubuntu 10.04 or is there a proper way to solve this?

+5
c limits
Nov 24 '10 at 13:41
source share
1 answer

POSIX determines that many of these restrictions are optional. If the FOO limit is not defined in limits.h , this means that the system may not have such a limit, or the limit may change at run time or depends on the path to which it is applied. In these cases, you use the pathconf , fpathconf or sysconf and the _PC_* and _SC_* macros, as in:

 path_max = pathconf("/", _PC_PATH_MAX); 

or

 page_size = sysconf(_SC_PAGE_SIZE); 

Unfortunately, GNU (the GNU C library) defines many restrictions as runtime-variable when they are actually constant on Linux, in some (in my opinion, very erroneous) I hope that someday the restrictions will be removed and the applications will be immediately able to take advantage of the elimination of restrictions. However, for application and kernel reliability, it is actually much better to have fixed limits if they are large enough (like Linux limitations).

+7
Nov 24 '10 at 15:41
source share



All Articles