I just noticed the macros named "_POSIX_*" in limits.h are (namewise) similar to the parameter of sysconf function. For example, there is the macro named "_POSIX_ARG_MAX", and I can also call sysconf with the argument of "_SC_ARG_MAX". Why do we need sysconf in the first place when we're totally free to use the macros in limits.h?
-
1The `_POSIX_*` ones are the minimum value that must be supported in order to conform to POSIX at all. – Tavian Barnes Mar 07 '17 at 16:06
-
@TavianBarnes Thank you~! It makes sense now. – eca2ed291a2f572f66f4a5fcf57511 Mar 07 '17 at 16:10
1 Answers
The _POSIX_*
values are the minimum requirement to be POSIX compliant. They will have the same value on all platforms. The particular value supported by the implementation may be higher.
From man sysconf
:
For variables or limits, typically, there is a constant
_FOO
, maybe defined in<limits.h>
, or_POSIX_FOO
, maybe defined in<unistd.h>
. The constant will not be defined if the limit is unspecified. If the constant is defined, it gives a guaranteed value, and a greater value might actually be supported. If an application wants to take advantage of values which may change between systems, a call tosysconf()
can be made. Thesysconf()
argument will be_SC_FOO
.
For example, _POSIX_ARG_MAX
is 4096. But sysconf(_SC_ARG_MAX)
may return a larger number if the system supports it.

- 12,477
- 4
- 45
- 118