6

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.

Jens
  • 69,818
  • 15
  • 125
  • 179
robert williams
  • 747
  • 2
  • 11
  • 18
  • its value is the value of the symbol, you normally don't have to know the value. Write your code with this symbol and never make any assumption about its real value. This is the way you will have portable code. – Jean-Baptiste Yunès Jun 11 '15 at 08:19

3 Answers3

3

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

  $ getconf _POSIX_PATH_MAX
  256
Jens
  • 69,818
  • 15
  • 125
  • 179
1

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;
}
Verma
  • 51
  • 7
0

#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.

alk
  • 69,737
  • 10
  • 105
  • 255