How to determine system value for _POSIX_PATH_MAX

亡梦爱人 提交于 2019-12-10 14:13:06

问题


Can anyone please tell me how to find the system value for _POSIX_PATH_MAX in Linux mint? I know that it is available in the <limits.h> file but I do not know how to find its value.


回答1:


The tool to use, according to POSIX, is named getconf(1):

  $ getconf _POSIX_PATH_MAX
  256



回答2:


One more way to get it's value.

#include "stdio.h"
#include "unistd.h"
#include "limits.h"

int main()
{
    printf ("Value :: %d \n", _POSIX_PATH_MAX);
    return 0;
}



回答3:


#define one of the following

#define _POSIX_SOURCE
#define _POSIX_C_SOURCE 1 /* or any value larger then 1 */
#define _XOPEN_SOURCE

before #includeing <limits.h>and the compiler will see _POSIX_PATH_MAX.

You also can specify this on the command line via the compiler option -D:

gcc -c main.c -D_POSIX_C_SOURCE=1

for example.



来源:https://stackoverflow.com/questions/30766163/how-to-determine-system-value-for-posix-path-max

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!