"Lewei Xu" <23*0*0*
8@s*u*e*t*u*a*e*u*a*> wrote:
> ... haha ...
??
> Before I read the post titled Macro Definitions, I was searching up the maximum path names in Linux systems. I stumbled across MAX_PATH which is defined in <limits.h> which is defined to be 4096 bytes. However, for MAX_PATH to be defined, I also had to use #define _POSIX_C_SOURCE 200809L.
>
> I also found that MAX_PATH was defined in <sys/param.h> and is the same number as MAXPATHLEN. Just a bit confused about what all these are, and the differences between them.
I believe that the reason for 2 such similar constants is their historic origins - MAXPATHLEN originally from the Unix world, and MAX_PATH from the Windows world.
I do most of my work on both Linux and macOS, ensuring that my code compiles with minimal reference to its environment.
With this, I always just include
sys/param.h
and use
MAXPATHLEN
.
On Ubuntu 23.04, today, the value is 4096; on macOS 14.0.1 it is 1024.