You are not logged in.
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?
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...
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)