UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

#1 2017-01-20 11:32 AM

eax
Member
Registered: 2017-01-20
Posts: 4

[SunOS] Right way to define PATH_MAX value

Hello,

I would like to implement program for GNU/Linux and other UNIX-like systems. For opening files I use PATH_MAX variable (from limits.h), but it doesn't work on, for example, SunOS.
How to use PATH_MAX on system without this variable or... what is the right way to implement multi-platform code that use PATH_MAX?

Of course, we can define it additionally:

#include<limits.h>
...
#ifndef PATH_MAX
#define PATH_MAX 4096
#endif

...but maybe there is more intelligent way to do that?

Thank you.

Offline

#2 2017-01-20 01:19 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,839
Website

Re: [SunOS] Right way to define PATH_MAX value

I think it should already be defined somewhere...  Try including <unistd.h>...  Or just grep through "/usr/include/*.h" for it...

You could also call pathconf() to get it, but that's not nearly as helpful as a simple macro, since I assume you want to use it for defining buffer sizes and such...

Offline

#3 2017-01-30 10:38 PM

eax
Member
Registered: 2017-01-20
Posts: 4

Re: [SunOS] Right way to define PATH_MAX value

Thanks for reply.

I think about some "similar" variable that exist on all Unix-like systems (or most of them).

#ifndef PATH_MAX
# ifdef _POSIX_PATH_MAX
# define PATH_MAX _POSIX_PATH_MAX
# endif
#endif

Last edited by eax (2017-01-30 11:06 PM)

Offline

Board footer

Powered by FluxBB